Forums Register Login

Difference between UserTransaction and EntityTransaction?

+Pie Number of slices to send: Send
What is the difference between getting a transaction from the EntityManager in a session bean as opposed to useing an injected UserTransaction? I have not
been anle to get the EntityTransaction to work in a session bean? Is EntityTransaction only for J2SE?

+Pie Number of slices to send: Send
Where et is a valid EntityManager
+Pie Number of slices to send: Send
Have you figured this out?
I just wanna post a question alike.
+Pie Number of slices to send: Send
In EJB Core 16.12 (Page 448):
The container must make the UserTransaction interface available to the enterprise beans that are allowed to use this interface (only session and message-driven beans with bean-managed transaction demarcation are allowed to use this interface) either through injection using the Resource annotation or in JNDI under the name java:comp/UserTransaction, in addition to through the EJBContext interface. The authenticationType and shareable elements of the Resource annotation must not be specified.

In EJB persistence spec, Page 130:

For stateful session beans with extended persistence contexts:
...
� When a business method of the stateful session bean is invoked, if the stateful session beanuses container managed transaction demarcation, and the entity manager is not already associated with the current JTA transaction, the container associates the entity manager with the current JTA transaction and calls EntityManager.joinTransaction. If there is a different persistence context already associated with the JTA transaction, the container throws the EJBException.
� When a business method of the stateful session bean is invoked, if the stateful session bean uses bean managed transaction demarcation and a UserTransaction is begun within the method, the container associates the persistence context with the JTA transaction and calls EntityManager.joinTransaction.
Grow a forest with seedballs and this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 3741 times.
Similar Threads
Session Facade vs Session Bean
what are differences between UserTransaction and EntityTransaction ?
EntityManagers and transactions
can some one explain
Session Facade vs Session Bean
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 01:34:43.