|
The fix for
HHH-6848
causes IllegalStateException when merging an entity results in merging more than one representation of the same detached entity.
For example, Hibernate throws IllegalStateException when merging entity 'x' if it has references to 2 detached entities 'y1' and 'y2' (obtained from different sessions), and y1 and y2 represent the same persistent entity.
When one of the representations is the "root" object being merged (e.g., session.merge( y1 )), and another representation is encountered on cascade-merge, the merge result should be as copied from the root object; and the representation encountered while cascading should be ignored.
When top-level merges are used to merge multiple representations of the same entity as in:
y = (Y) s.merge( y1 ); y = (Y) s.merge( y2 );
The state from y2 should "win".
In other cases, one representation will "win"; any other representations will be ignored. Because cascade-order is indeterminate, it will not be possible to know which will be the winner.
It is possible to log the current database state, the winner and losers.
We'll need to work out details about what gets logged and the log level (INFO, WARN, ...)
|