在Cassandra中,列类型设置为Date,而在Model类中,字段类型设置为带有getter和setter的java.util.Date.在com.datastax.driver.mapping.Mapper.save期间,我得到以下异常:
Codec not found for requested operation: [date <-> java.util.Date]
Caused by: com.datastax.driver.core.exceptions.CodecNotFoundException: Codec not found for requested operation: [date <-> java.util.Date]
at com.datastax.driver.core.exceptions.CodecNotFoundException.copy(CodecNotFoundException.java:56)
at com.datastax.driver.core.exceptions.CodecNotFoundException.copy(CodecNotFoundException.java:25)
at com.datastax.driver.mapping.DriverThrowables.propagateCause(DriverThrowables.java:41)
at com.datastax.driver.mapping.Mapper.save(Mapper.java:272)
DATE <-> com.datastax.driver.core.LocalDate : use getDate()
最佳答案
您必须将java.util.Date转换为com.datastax.driver.core.LocalDate
原文链接:https://www.f2er.com/java/437372.html例:
LocalDate localDate = LocalDate.fromMillisSinceEpoch(date.getTime());