Hi,
See as a reference the https://community.jboss.org/message/794633#794633 thread.
In an application server, that is JavaEE 6 compliant, which of EntityManager.close() and JTA Synchronization.afterCompletion() should be closed first?
Based on the persistence specification:
7.9.1 Container Responsibilities:
After the JTA transaction has completed (either by transaction commit or rollback), The container closes the entity manager by calling EntityManager.close.
I am using DataNucleus (DN) 3.2 as a Persistence provider, and DN expects the Transaction afterCompletion() to be triggered BEFORE the EntityManager.close(). It seems that the opposite is triggered by JBoss. So I wonder if both are correct or if one should be called before another based on either JTA or Persistence JSRs?
Based on the thread dump, arjuna calls first:
at org.datanucleus.api.jpa.JPAEntityManager.close(JPAEntityManager.java:194)
at org.jboss.as.jpa.transaction.TransactionUtil$SessionSynchronization.afterCompletion(TransactionUtil.java:193)
(EntityManager.close() is called first)
Then JTA after completion:
at org.datanucleus.TransactionImpl.internalPostCommit(TransactionImpl.java:563)
at org.datanucleus.JTATransactionImpl.afterCompletion(JTATransactionImpl.java:429)
at com.arjuna.ats.internal.jta.resources.arjunacore.SynchronizationImple.afterCompletion(SynchronizationImple.java:96)
Thanks