Spring Cassandra模型映射

时间:2018-02-19 10:36:39

标签: java spring spring-boot cassandra datastax

我有一张表格如下

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中处理Cassandra数据类型,例如timestamptimedate

1 个答案:

答案 0 :(得分:4)

┌───────────┬────────────────────────────────────────┐
│ 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