【问题标题】:Spring Cassandra model mappingSpring Cassandra 模型映射
【发布时间】:2018-07-29 13:46:31
【问题描述】:

我有一张如下表

col1 text,
col2 timestamp,
col3 text,
col4 text,
col5 text,
col6 date,
col7 time,

我不知道如何为上表创建一个 bean 类。 到目前为止,我已经创建了一个带有以下键的 bean。但它不起作用

@PrimaryKey
String col1;

Date col2;

String col3;

String col4;

String col5;

Date col6;

String col6;

请帮助我在 Spring 中处理 timestamptimedate 等 Cassandra 数据类型。

【问题讨论】:

    标签: java spring spring-boot cassandra datastax


    【解决方案1】:
    ┌───────────┬────────────────────────────────────────┐
    │ timestamp │ java.util.Date                         │
    ├───────────┼────────────────────────────────────────┤
    │ date      │ com.datastax.driver.core.LocalDate     │
    ├───────────┼────────────────────────────────────────┤
    │ time      │ long                                   │
    └───────────┴────────────────────────────────────────┘
    

    1. Spring Data for Apache Cassandra - 13.1. Data Mapping and Type Conversion
    2. Java Driver for Apache Cassandra - CQL to Java type mapping

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-05-06
    • 1970-01-01
    • 1970-01-01
    • 2015-05-04
    • 2021-09-01
    • 2016-10-02
    • 2016-07-18
    • 1970-01-01
    相关资源
    最近更新 更多