I have a child entity that has two parent entities (the two parents itself have another common parent, but for simplicity I focus only on the three entities):
I use EntityManager.merge() to apply my changes:
if all objects are new, everything is fine
if OtherParent exists and Parent and Child are new, everything is fine
if OtherParent and Parent exist and Child is new, everything is fine
However if Parent already exists and OtherParent and Child are new, I get an EntityNotFoundException because directly after cascadeOnMerge() Parent tries to load Child (which INSERT has not been executed yet) in copyValues():
Please advise how to further troubleshoot this issue, thank you.
Unfortunately I can't provide a > 4.2 test case because this application still relies on discontinued ejb3configuration.
But I was hoping to get a comment or an idea what I could do to tackle this issue down, any help is much appreciated.
You can easily provide a test case using the resources described at https://github.com/hibernate/hibernate-orm/wiki/Test-Case-Guide. I doubt that your issue is specific to MySQL. You should be able to reproduce your issue using the default dialect.
You are right I was able to setup a testcase. Unfortunately the error does not occur with 5.2.2, whereas the testcase can successfully reproduce the error with 4.2.21 (also 4.3.11)
Thank you , I merged changes from into my 4.2.20 bundle.