Merging of new entities can fail depending on cascade order

Description

Depending on the initialization order of entities a cascaded merge is failing with an IllegalStateException like:

The attached project

can be used to reproduce the issue.

Steps to reproduce the Issue:

1.) Build the attached project using Maven
2.) Install Wildfly 12
3.) Copy the build module:
cp -a $PROJECT_ROOT/playground-module/target/jboss-modules/org/ $JBOSS_HOME/modules/
4.) Copy the build application:
cp $PROJECT_ROOT/playground-app/ear/target/playground-app.ear $JBOSS_HOME/standalone/deployments/
5.) Start the server
6.) Run the client application using Maven:
mvn -f playground-app/client/pom.xml exec:exec

Environment

This occurs with Hibernate 5.1.10 on Wildfly 12 as well as with Hibernate 5.1.12 on JBoss EAP 7.1.1.

Assignee

Gail Badner

Reporter

Joerg Baesner

Fix versions

Labels

None

backPortable

Backport?

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Worked in

4.2.16

Components

Affects versions

Priority

Major
Configure