updating one to many sometimes fails

#1

we did setup automated tests for our system and it seams that in around 1 of 100 cases the update of a one to many collection is not working.

Definition:

@OneToMany(fetch=FetchType.LAZY)
@Index
public List<ObjectNode> childNodes = new ArrayList<ObjectNode>();

change of the childNodes within a transaction (a newly created object is added):

JDOHelper.makeDirty(this, "childNodes");

Do we miss anything to make that 100% reliable ?

 

 

#2

It is difficult to determine the exact cause with the information provided. To ensure reliable updates, the instance must be associated with an active transaction on the EntityManager (i.e., it must not be detached).

The observed inconsistency suggests a possible concurrency issue. This could occur if the same EntityManager is accessed from multiple threads concurrently, or if the same entity instance is modified from different threads without proper synchronization. In such cases, changes made in one thread may not yet be visible to another due to CPU caching or the lack of memory synchronization. It is important to remember that EntityManager is not thread-safe, and JPA-managed entity instances cannot be accessed concurrently from multiple threads. All modifications should be confined to a single thread per transaction to ensure consistency.

ObjectDB Support

Reply