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
This occurs with Hibernate 5.1.10 on Wildfly 12 as well as with Hibernate 5.1.12 on JBoss EAP 7.1.1.
Fixed in master, 5.2, and 5.1 branches.