Vish Shukla wrote:Hi all,
I am going through Mikalai Zaikin's guide for SCBCD preparation. I just came across a statement that says,
When a JTA application-manager entity manager is used, if the entity manager is created outside the scope of the current JTA transaction, it is the responsibility of the application to associate the entity manager with the transaction by calling EntityManager.joinTransaction.
.
In this statement, I dont exactly understand what is the "scope of the current JTA transaction". It would be great if someone can explain this with example.
As an example : Suppose In a statefull session bean with bean managed trannsactions, the entity manager is created in a @PostConstruct method, with the EntityManagerFactor.createntitymanager.
So this entitymanager is created outside a JTA transaction.
A business method can now start a UserTransaction. The entitymanager is not associated with that transaction, and you will have to call joinTransaction.
when the business method ends you can commit the transaction.