I implemented the following pattern:
@Transactional { Parent p = new Parent(); entityManager.merge(p); Child c = new Child((); p.getChildren().add(c); }
The children don't get written to the database. If I change to order to
@Transactional { Parent p = new Parent(); Child c = new Child((); p.getChildren().add(c); entityManager.merge(p); }
everything is fine.
If it is not reproducable with Collection.add, in fact I used addAll. So perhaps the issue lies in addAll (did not test the add-Case).
|