BlackPOP
BlackPOP

Reputation: 5747

Spring Cassandra model mapping

I have a table as following

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

I do not know how to create a bean class for the above table. So far i have created a bean with following keys. But it does not work

@PrimaryKey
String col1;

Date col2;

String col3;

String col4;

String col5;

Date col6;

String col6;

Please help me to handle Cassandra datatype such as timestamp, time and date in Spring.

Upvotes: 3

Views: 1440

Answers (1)

Andrew
Andrew

Reputation: 49656

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

Upvotes: 4

Related Questions