0
votes

I am using java8 and cassandra in my application. The datatype of current_date in cassandra table is 'date'. I am using entities to map to the table values. and the datatype in entity for the same field is com.datastax.driver.core.LocalDate.

When I am trying to retrieve a record 'Select * from table where current_date='2017-06-06';' I am getting the following error'

Caused by: com.datastax.driver.core.exceptions.CodecNotFoundException: Codec not found for requested operation: ['org.apache.cassandra.db.marshal.SimpleDateType' <-> com.datastax.driver.core.LocalDate]

1

1 Answers

-1
votes

By default, Java driver will map date type into com.datastax.driver.core.LocalDate Java type.

If you need to convert date to java.time.LocalDate, then you need to add extras to your project : You can specify codec for given column only:

 @Column(codec = LocalDateCodec.class) java.time.LocalDate current_date ;

If these two didnot work, please have a look into the code how you are creating the session,cluster etc to connect to database. Since date is a new addition to cassandra data type, Protocol version can also have an impact. Update the version accordingly