Parent entity tries to load transient child entity during cascade

Description

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):

Parent:

OtherParent:

Child:

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():

Stack trace:

Please advise how to further troubleshoot this issue, thank you.

Environment

None

Activity

Show:
Gail Badner
August 25, 2016, 12:08 AM
Edited

Please attach a short but complete test case that reproduces the reported bug.

4.2 branch is no longer supported. Please provide a test using 5.2.

Markus
August 25, 2016, 12:23 AM

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.

Gail Badner
August 25, 2016, 5:53 AM
Edited

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.

Markus
August 28, 2016, 3:39 AM
Edited

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)

Markus
August 30, 2016, 3:17 AM

Thank you , I merged changes from into my 4.2.20 bundle.

Assignee

Gail Badner

Reporter

Markus

Fix versions

None

Labels

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Critical
Configure