Date saved but retrieved null in ElementCollection (or Embedded) property
See original GitHub issueI 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 aList<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
’sfind
method to fetch an instance by itsuuid
, and it contains all values, including thedate
column, and its datapoints contain their values but thetimestamp
field in every datapoint isnull
.
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?
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Hibernate JPA not inserting rows in collection table for null ...
When the collection is retrieved from the database, it has fewer elements than when it was stored because those that are null are...
Read more >Java Persistence/Embeddables - Wikibooks
TopLink / EclipseLink : Support an embedded reference being null . ... and define property get/set methods for the relationship that set the...
Read more >JPA - Persisting Collections of embeddable type by ... - LogicBig
Just like the collection of basic type, a collection of embeddable class can be persisted by using @ElementCollection on the collection ...
Read more >Chapter 7. Collection mapping - Red Hat on GitHub
Two entities cannot share a reference to the same collection instance. Due to the underlying relational model, collection-valued properties do not support null...
Read more >ElementCollection not updated correctly if the Embeddable ...
With MySQL the DELETE fails to delete any rows where the property is a nullable property and the previous value was null. This...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hi @milosjajac,
This issue is fixed and will be available in the next Kundera release.
Hi @milosjajac,
Seems like an issue from Kundera side.