Time in Joda Time in Cassandra Date

What is the recommended way to match Joda time with a Cassandra date type when matching with Spring -data cassandra module? Is there an equivalent to @Type annotation in JPA / Hibernate?

+6
source share
2 answers

This issue is resolved with this pending ticket: https://datastax-oss.atlassian.net/browse/JAVA-721

Once resolved, matching the java driver will allow matching custom types using the cassandra data model.

+1
source

I did not find a clean way to register converters using spring -data-cassandra.

You can use java.util.Date for your fields (the infrastructure will access them through reflection) and use encapsulation to provide the type you need:

 @Table("measure") public class Measure { @PrimaryKey("id") private String id; @Column("timestamp") private java.util.Date timestamp; @Column("data") private Double data; /** * Convert java.util.Date -> org.joda.time.DateTime */ public DateTime getTimestamp() { // Simple example, beware of the timezone return new DateTime(ts); } // Constructor and other getters omitted } 
0
source

Source: https://habr.com/ru/post/982750/


All Articles