Hibernate "IllegalStateException: An entity copy was already assigned to a different entity" in JBoss EAP 6
Issue
Migrating to EAP 6/Hibernate 4 and encountering an exception like the following
ERROR [org.jboss.as.ejb3.invocation] (http-/0.0.0.0:443-1) JBAS014134: EJB Invocation failed on component SatelliteDao for method public abstract long com.xzy.Dao.persist(com.xyz.SomeEntity) throws java.lang.IllegalStateException: An entity copy was already assigned to a different entity.
at org.jboss.as.ejb3.tx.CMTTxInterceptor.handleExceptionInOurTx(CMTTxInterceptor.java:165) [jboss-as-ejb3-7.1.2.Final-redhat-1.jar:7.1.2.Final-redhat-1]
...
Caused by: java.lang.IllegalStateException: An entity copy was already assigned to a different entity.
at org.hibernate.event.internal.EventCache.put(EventCache.java:184) [hibernate-core-4.1.3.Final-redhat-1.jar:4.1.3.Final-redhat-1]
at org.hibernate.event.internal.DefaultMergeEventListener.entityIsDetached(DefaultMergeEventListener.java:285) [hibernate-core-4.1.3.Final-redhat-1.jar:4.1.3.Final-redhat-1]
at org.hibernate.event.internal.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:151) [hibernate-core-4.1.3.Final-redhat-1.jar:4.1.3.Final-redhat-1]
Environment
- Red Hat JBoss Enterprise Application Platform (EAP) 6
- Hibernate 4
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.
Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.
