| Codec not found for requested operation: [timestamp <-> com.datastax.driver.core.LocalDate] | Antoine Toulme | 11.05.16 00:06 | Hello, I am trying to upgrade spring-data-cassandra to work with Cassandra 3.x. I unfortunately am hitting errors. My setup is using cassandra-driver-core 3.0.1, cassandra-driver-dse 3.0.0-rc1 (is there a new release out since?). Here is the stacktrace. It occurs when reading a property of type timestamp, to be cast into a Date field. This works well with Cassandra 2.2.5. Any help is very welcome. com.datastax.driver.core.exceptions.CodecNotFoundException: Codec not found for requested operation: [timestamp <-> com.datastax.driver.core.LocalDate] com.datastax.driver.core.CodecRegistry.notFound(CodecRegistry.java:679) com.datastax.driver.core.CodecRegistry.createCodec(CodecRegistry.java:526) com.datastax.driver.core.CodecRegistry.findCodec(CodecRegistry.java:506) com.datastax.driver.core.CodecRegistry.access$200(CodecRegistry.java:140) com.datastax.driver.core.CodecRegistry$TypeCodecCacheLoader.load(CodecRegistry.java:211) com.datastax.driver.core.CodecRegistry$TypeCodecCacheLoader.load(CodecRegistry.java:208) com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3542) com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2323) com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2286) com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2201) com.google.common.cache.LocalCache.get(LocalCache.java:3953) com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:3957) com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4875) com.datastax.driver.core.CodecRegistry.lookupCodec(CodecRegistry.java:480) com.datastax.driver.core.CodecRegistry.codecFor(CodecRegistry.java:448) com.datastax.driver.core.CodecRegistry.codecFor(CodecRegistry.java:430) com.datastax.driver.core.AbstractGettableByIndexData.codecFor(AbstractGettableByIndexData.java:69) com.datastax.driver.core.AbstractGettableByIndexData.getDate(AbstractGettableByIndexData.java:174) com.datastax.driver.core.AbstractGettableData.getDate(AbstractGettableData.java:26) org.springframework.data.cassandra.convert.ColumnReader.get(ColumnReader.java:93) org.springframework.data.cassandra.convert.ColumnReader.get(ColumnReader.java:39) org.springframework.data.cassandra.convert.ColumnReader.get(ColumnReader.java:31) org.springframework.data.cassandra.convert.BasicCassandraRowValueProvider.getPropertyValue(BasicCassandraRowValueProvider.java:64) org.springframework.data.cassandra.convert.MappingCassandraConverter.readPropertyFromRow(MappingCassandraConverter.java:185) org.springframework.data.cassandra.convert.MappingCassandraConverter$1.doWithPersistentProperty(MappingCassandraConverter.java:149) org.springframework.data.cassandra.convert.MappingCassandraConverter$1.doWithPersistentProperty(MappingCassandraConverter.java:144) org.springframework.data.mapping.model.BasicPersistentEntity.doWithProperties(BasicPersistentEntity.java:318) org.springframework.data.cassandra.convert.MappingCassandraConverter.readPropertiesFromRow(MappingCassandraConverter.java:144) org.springframework.data.cassandra.convert.MappingCassandraConverter.readEntityFromRow(MappingCassandraConverter.java:136) org.springframework.data.cassandra.convert.MappingCassandraConverter.readRow(MappingCassandraConverter.java:116) org.springframework.data.cassandra.convert.MappingCassandraConverter.read(MappingCassandraConverter.java:201) org.springframework.data.cassandra.core.CassandraConverterRowCallback.doWith(CassandraConverterRowCallback.java:47) org.springframework.data.cassandra.core.CassandraTemplate.selectOne(CassandraTemplate.java:611) org.springframework.data.cassandra.core.CassandraTemplate.selectOne(CassandraTemplate.java:456) org.springframework.data.cassandra.core.CassandraTemplate.selectOneById(CassandraTemplate.java:375) org.springframework.data.cassandra.repository.support.SimpleCassandraRepository.findOne(SimpleCassandraRepository.java:69) sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) java.lang.reflect.Method.invoke(Method.java:498) org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.executeMethodOn(RepositoryFactorySupport.java:503) org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.doInvoke(RepositoryFactorySupport.java:488) org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:460) org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:61) org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92) org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:208) com.sun.proxy.$Proxy42.findOne(Unknown Source) |
| Re: Codec not found for requested operation: [timestamp <-> com.datastax.driver.core.LocalDate] | Alexandre Dutra | 11.05.16 01:17 | Hello Antoine, The error you are seeing is "normal" because there is no built-in codec that maps a CQL TIMESTAMP to a LocalDate instance. The correct mappings that the driver offers out of the box for temporal types are: TIMESTAMP <-> java.util.Date : use getTimestamp() TIME <-> long : use getTime() DATE <-> com.datastax.driver.core.LocalDate : use getDate() So you should actually be using AbstractGettableData.getTimestamp(). That said, the error message is a bit cumbersome and another user has already filed a similar Jira, JAVA-1176. We decided to improve the error message to include a hint about what to do to fix it, see JAVA-1177. Also please take a look at the upgrade guide if you are migrating from an older version of the driver as a lot of breaking changes exist between 2.1.x and 3.0.x. Hope that helps, Alexandre -- -- Alexandre Dutra Driver & Tools Engineer @ DataStax |
| Re: Codec not found for requested operation: [timestamp <-> com.datastax.driver.core.LocalDate] | Antoine Toulme | 11.05.16 09:23 | Thank you for your great advice. I should have a patch ready soon. I did follow the upgrade guide and provided a patch to spring-data-cassandra according to its guidelines. It was very helpful, thank you! Link to the patch: https://github.com/spring-projects/spring-data-cassandra/pull/52 |
| Re: Codec not found for requested operation: [timestamp <-> com.datastax.driver.core.LocalDate] | Günther Grill | 28.05.19 05:59 | Is this still valid for 4.0.1? I've a table with timestamp and try to insert a Date. The error I get is: com.datastax.oss.driver.api.core.type.codec.CodecNotFoundException: Codec not found for requested operation: [TIMESTAMP <-> java.util.Date] What type is the appropriate one here to bind with timestamp? regards |
| Re: Codec not found for requested operation: [timestamp <-> com.datastax.driver.core.LocalDate] | Alexandre Dutra | 28.05.19 06:03 | Hi, Starting with driver 4.0, the CQL type timestamp is not mapped to java.util.Date anymore, but to java.time.Instant. See the following links for more details: Thanks, Alex Dutra --You received this message because you are subscribed to the Google Groups "DataStax Java Driver for Apache Cassandra User Mailing List" group. Alexandre DUTRA Driver & Tools Engineer | alexand...@datastax.com |