Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] JEE Application Managed EntityManager Error

Thanks Michael,

Your point well understood about two persistence units. So to conclude:

* If you want to mix-use an application managed EM inside JEE, you should use a separate persistence contexts.

Does this conclusion holds true even if we do not want to use the application managed EM for transactions i.e. use it for queries / read only purpose?

 My experience says that even if you are not using the application managed EM for transactions still the queries you perform on this EM will become part of current JTA transaction. Why? to explain please understand what i tried to do in my application.

Inside my JPA entity listeners (preUpdate, prePersist etc) i wanted to access DB to perform some validation. I knew that JPA specs say that do not do this. But still i performed queries on the same entity manager which was being used in current transaction. The result was a flush to DB as soon as i access it inside a JPA listener. So, to overcome this i used a different / new entity manager from the one which was being used in current transaction. Querying on 2nd entity manager did not effect 1st / current EM and transaction of 1st EM. These tests were performed in JSE (RESOURCE_LOCAL). But when i took it to JEE, 2nd EM became part of JTA even when i made 2nd EM to be application managed.


Regards,
Jehanzeb Qayyum


Back to the top