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

Moderator: admin

Post Reply
ericrlessa
Posts: 5
Joined: Thu Oct 17, 2013 9:26 pm
Contact:

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

Post by ericrlessa »

RESOURCE_LOCAL transaction-type can be only used in Application-managed Entity Manager? In this question, the Statefull Session Bean should use Application-managed Entity Manager?

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

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

Post by admin »

I am not sure I understand your question. In this question, em could be injected also. It doesn't have to be RESOURCE_LOCAL.

HTH,
Paul.
If you like our products and services, please help us by posting your review here.

ioan.b
Posts: 3
Joined: Sun Nov 30, 2014 5:00 am
Contact:

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

Post by ioan.b »

em.getTransaction() will throw IllegalStateException if invoked on a JTA entity manager.

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

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

Post by johnlong »

Code: Select all

1. EntityTransaction et = em.getTransaction();
2. et.setRollbackOnly(); 
Could you please describe case(s) in which et instance would be non-active transaction on line 2?

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

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

Post by admin »

What if processAccount is the first method to be invoked. In the given code, there is no call to begin. Thus the transaction is not active at this point and therefore a call to setRollBackOnly will throw IllegalStateException.

HTH,
Paul.
If you like our products and services, please help us by posting your review here.

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

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

Post by johnlong »

I see now, transaction is not active because begin has not been called, thank you.

Post Reply

Who is online

Users browsing this forum: No registered users and 39 guests