About Question enthuware.oce-jpad.v6.2.374 :

Moderator: admin

Post Reply
johnlong
Posts: 185
Joined: Mon Jun 20, 2016 5:06 pm
Contact:

About Question enthuware.oce-jpad.v6.2.374 :

Post by johnlong » Sat Dec 24, 2016 5:00 pm

Transaction management type of a session bean and type of entity manager (container managed or bean managed) are two different things. Any type of entity manager can be enlisted in a transaction started by a session bean with bean managed transactions.
Does it mean that if session bean is annotated @TransactionManagement(CONTAINER) we still can inject EntityManager (or EntityManagerFactory with @PersistenceUnit) with @PersistentContext and get application-managed transactions?

If yes, how shall we get transaction instance or proxy : from EJBContext.getUserTransaction(), get it injected with @Resource or @Inject annotations?
Or it means that we can only "manage" entity manager, but we do not control transaction and transaction-management is still done by container?

admin
Site Admin
Posts: 8307
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.oce-jpad.v6.2.374 :

Post by admin » Sun Dec 25, 2016 12:31 pm

No, it doesn't mean that. What it means is that if one bean (A) calls another bean (B), then the choice of type of EntityManager for bean B is not affected by the fact that the transaction was started by a bean with bean managed transactions.
IOW, it does not matter how to start a transaction in a bean. It does not affect the type of EntityManager of another bean.
If you like our products and services, please help us by posting your review here.

johnlong
Posts: 185
Joined: Mon Jun 20, 2016 5:06 pm
Contact:

Re: About Question enthuware.oce-jpad.v6.2.374 :

Post by johnlong » Sun Dec 25, 2016 6:57 pm

Clear, thanks.

unvector
Posts: 18
Joined: Sun Jun 21, 2015 2:56 am
Contact:

Re: About Question enthuware.oce-jpad.v6.2.374 :

Post by unvector » Sun Apr 09, 2017 11:24 am

Lets take into consideration option 1.
Could we also inject two entity managers (instead of two datasources as in the example) from distinct persistent units and synchronize them with single bean-managed transaction started by UserTransaction?

admin
Site Admin
Posts: 8307
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.oce-jpad.v6.2.374 :

Post by admin » Sun Apr 09, 2017 9:16 pm

Yes, that can be done.
If you like our products and services, please help us by posting your review here.

Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests