| I think I have a pretty good idea about how to fix this now. I've added a branch to my fork to work on this: https://github.com/gbadner/hibernate-core/tree/HHH-3799-master To start, I've made a very quick-and-dirty change that should fix this issue, but it needs to be refined because it is not going to perform well. For now, it simply clears and re-inserts the elements in every collection that gets initialized within a top-level load operation. It would help a lot if someone could try out this this fix. If it does not work for you, then please attach a runnable test case that reproduces the failure. Test templates can be found at https://github.com/hibernate/hibernate-test-case-templates. I would really appreciate feedback before refining the fix. A "refined" fix would only clear and re-insert the elements if all of the following are true: 1) collection element type is an entity or an embeddable (or sub-embeddable, etc) that contains an entity; 2) collection element type or subclasses override Object#hashCode; 3) an entity element or an entity within an embeddable element has org.hibernate.engine.spi.Status.LOADING at the time that it was added to the collection; 4) the hashCode for the element before inserting the element is different from the hashCode of the element after the top-level load completes. |