I have an object of type Instance which contains an @ElementCollection of type Datapoint. Each datapoint has a timestamp and a value. In a test, I create some instances with their datapoints and save them, however, when I read any of those instances back from the database, the value for datapoints is set but the timestamp is null.
I am using:
Cassandra 3.11.2
Kundera 3.12
persistence.xml
<persistence-unit name="cassandra_pu">
<provider>com.impetus.kundera.KunderaPersistence</provider>
<properties>
<property name="kundera.nodes" value="localhost"/>
<property name="kundera.port" value="9042"/>
<property name="kundera.keyspace" value="d2lablite"/>
<property name="kundera.dialect" value="cassandra"/>
<property name="kundera.ddl.auto.prepare" value="create" />
<property name="kundera.client.lookup.class" value="com.impetus.kundera.client.cassandra.dsdriver.DSClientFactory" />
</properties>
</persistence-unit>
Datapoint.java
@Embeddable
public class Datapoint {
@Column(name="timestamp")
@Temporal(TemporalType.TIMESTAMP)
private java.util.Date timestamp;
@Column(name="value")
private double value;
public Datapoint() { }
// Getters, setters
}
Instance.java
@Entity
@Table(name="instances")
public class Instance {
@Id
@Column(name="uuid")
private String uuid;
@Column(name="param")
private String param;
@ElementCollection
@Column(name="datapoints")
private List<Datapoint> datapoints;
@ElementCollection
@Column(name="metadata")
private Map<String, String> metadata;
@Temporal(TemporalType.TIMESTAMP)
@Column(name="date")
private Date date;
public Instance() { }
}
So what I do is:
- Create an
Instance, create a List<Datapoint>, set it to instance and persist the instance
- Check via cqlsh that the instance is saved and all datapoints have the timestamp saved as well
- Use the
EntityManager's find method to fetch an instance by its uuid, and it contains all values, including the date column, and its datapoints contain their values but the timestamp field in every datapoint is null.
I have also tried to use @Embedded and only 1 Datapoint instead of a list and the result is the same, timestamp is null.
What did I miss?
I have an object of type
Instancewhich contains an@ElementCollectionof typeDatapoint. Each datapoint has a timestamp and a value. In a test, I create some instances with their datapoints and save them, however, when I read any of those instances back from the database, the value for datapoints is set but the timestamp is null.I am using:
Cassandra 3.11.2
Kundera 3.12
persistence.xml
Datapoint.java
Instance.java
So what I do is:
Instance, create aList<Datapoint>, set it to instance and persist the instanceEntityManager'sfindmethod to fetch an instance by itsuuid, and it contains all values, including thedatecolumn, and its datapoints contain their values but thetimestampfield in every datapoint isnull.I have also tried to use
@Embeddedand only 1Datapointinstead of a list and the result is the same,timestampisnull.What did I miss?