【发布时间】:2018-06-18 05:17:08
【问题描述】:
我在我的应用程序中使用 java8 和 cassandra。 cassandra 表中 current_date 的数据类型是“日期”。我在 java 中使用实体映射到表值。并且同一字段的实体中的数据类型是 java.sql.Date。
当我试图检索记录'Select * from table where current_date='2017-06-06';'时我收到以下错误'
`Caused by: com.datastax.driver.core.exceptions.CodecNotFoundException: Codec not found for requested operation: ['org.apache.cassandra.db.marshal.SimpleDateType' <-> java.sql.Date]
我尝试过各种数据类型,例如:
com.datastax.driver.core.LocalDate, java.util.Date ,com.google.common.reflect.TypeToken
所有都返回相同的错误。
我已推荐http://docs.datastax.com/en/developer/java-driver/3.1/manual/custom_codecs/extras/。
但我被困住了。请帮帮我。
【问题讨论】:
-
@AshrafulIslam 将数据类型声明为 com.datastax.driver.core.LocalDate 不起作用。遇到同样的问题。 java中有直接的数据类型吗?
标签: java cassandra datastax-java-driver