omar al kababji wrote:By default method will be Container Managed Transaction,
Specs wrote:joinTransaction method should be called on a JTA application managed EntityManager that was created outside the scope of the active transaction to associate it with the current JTA transaction.
omar al kababji wrote:i think that you are calling your method directly so there is currently no transaction.
When an EntityManager with an extended persistence context is used, the persist, remove, merge, and
refresh operations may be called regardless of whether a transaction is active. The effects of these oper-
ations will be committed to the database when the extended persistence context is enlisted in a transac-
tion and the transaction commits.
The scope of the persistence context of an application-managed entity manager is extended. It is the
responsibility of the application to manage the lifecycle of the persistence context.
Raf Szczypiorski wrote:
If you really want to provoke an exception, call flush() yourself - TransactionRequiredException on the way.
Raf Szczypiorski wrote:Can you change it to be stateless bean? See what happens.
Caused by: javax.persistence.TransactionRequiredException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
... 17 more
I did not understand how you drew the conclusion you did about transactional context. To me all this is telling me is that init ran before addCustomer. I am not sure how anything about their transactional context can be derived from this. Can you explain this a little bit.