|
I've reproduced this issue in both hibernate-core and with EntityManager.
This happens when new (transient) entities are added to an uninitialized "inverse" bag owned by a persistent entity. These new entities are added to AbstractPersistentCollection.operationQueue (as DelayedOperation objects). The merge operation is cascaded to the new entities. After merging, It does not appear that the entities in the DelayedOperation are replaced with the merged entities.
If both merge and saveOrUpdate (or persist for EntityManager) operations are cascaded to the bag, then the entities are added twice, resulting in duplicated inserts.
I'm looking into why the entities in the DelayedOperation are not replaced.
|