preUpdate-methods are called when there is no change

Type: BugVersion: 2.5.3Priority: NormalStatus: ClosedReplies: 1
#1

Dear Support Team,

we ran into some difficulties with a database. When fetching a entity using the EntityManager and afterwards calling "iterator().next()" a transaction begin/commit will end up in updating the Entity even there was no change.

RepositoryModelData repository = connection.find(RepositoryModelData.class, 1);
repository.getObsTypes().iterator().next();
connection.getTransaction().begin();
connection.getTransaction().commit(); // --> will result in a call of @PreUpdate annotated methods

We attached a simplified test case where only 2 reduced versions of the entities are available. But it still shows the unexpected behavior. To reproduce just run the "EntryPoint" class.

 

 

application/zip iconTestProject.zip (16.1KB)
Test Eclipse Project
#2

This seems to be a side effect of using a HashSet of objects with no user defined hashCode method.

Objects in a persistent HashSet (and key objects in a persistent HashMap) should have a meaningful hashCode and equals methods based on the object id or content (and not the methods that are inherited from java.lang.Object, which are based on the object address, which is not fixed).

ObjectDB Support
ObjectDB - Fast Object Database for Java (JPA/JDO)

Post Reply

To post a reply and/or subscribe to update notifications - please login