I personally encountered this problem while trying to remove a workaround for https://hibernate.atlassian.net/browse/HHH-15604, which was fixed. It seems we have a similar bug on embeddeds ( HHH-15604 Resolved was about element collections of embeddeds, which I guess are treated differently). Affects 6.2.0.CR2 and the latest main (commit 100d9351cdcc6afa6120ee321c8f2bb07e13fdcb) for sure. Don’t know about 6.1. There seem to be different problems on 5.6, but personally I never encountered them, so let’s focus on 6.2? The following model will cause Hibernate ORM to mix up associations from the root entity and the embedddables, eventually leading to incorrect loading of associations. Judging from SQL logs, persisting associations seems to work fine.
Note the situation exposed in this issue seems a bit exotic, but it hints at mixups in Hibernate ORM internals which could have more widespread consequences, so I think it’s still worth fixing. I will provide a reproducer soon. |