EJB 3.0 Transaction Propagation and POJO

D

Dhananjay

Hi,

Can any of you help me out in EJB 3.0 transaction?

Let me present the flow of the application:

EJB 3.0 (SLSB) ----->JDK Proxy ----> POJO(Business Logic) --->JDK
Proxy --->POJO(For Data Access) --->DBManager(All the database
operation including creating a connection, closing, DML execution)

Note: I am using CMT.

My concerns are:

1. Is the above mentioned flow upto DBManager does Transaction context
propagate?
2. If Yes how can I get that Transation Context in POJOs?
3. If no How can I apply transaction demarcation?
4. If POJO calls another SLSB, what are affect on transaction context?

Regards
Dhananjay
 
O

Owen Jacobson

Hi,

Can any of you help me out in EJB 3.0 transaction?

Let me present the flow of the application:

EJB 3.0 (SLSB) ----->JDK Proxy ----> POJO(Business Logic) --->JDK
Proxy --->POJO(For Data Access) --->DBManager(All the database
operation including creating a connection, closing, DML execution)

Note: I am using CMT.

My concerns are:

1. Is the above mentioned flow upto DBManager does Transaction context
propagate?
2. If Yes how can I get that Transation Context in POJOs?
3. If no How can I apply transaction demarcation?
4. If POJO calls another SLSB, what are affect on transaction context?

All of the calls into normal java objects[0] from the stateless bean
occur in the same transaction context. However, normal java objects
aren't inherently transaction-aware -- if you need to manipulate
transactional resources from a normal java object, it's up to you to
provide those resources to the object in a form it understands.

Particularly, RuntimeException and
@ApplicationException(rollback=true) exceptions only cause transaction
rollback when they cross a transaction boundary (like an EJB call), so
if the Data Access object in your diagram throws a RuntimeException
that gets caught in the Business Logic object, no transaction rollback
will occur.

Your DBManager will take part in the same transaction if, and only if,
it either gets passed a Connection or DataSource obtained within the
transaction (either injected into the session bean or obtained from
JNDI) or it obtains one itself via JNDI (either directly or
indirectly).

If any of those objects calls a session bean in the same container (or
if your container supports transaction propagation between servers)
then the called bean will participate in the same transaction
(assuming it's marked as either REQUIRES or SUPPORTS). Otherwise, if
it's REQUIRES (and the transaction can't be propagated) or
REQUIRES_NEW, a new transaction will begin for that call only.

[0] I detest the moniker "POJO".
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top