0
votes

With respect to EJB 3.0 transaction propagation, I have the following basic question.

This is my scenario : EJB Service -> POJO -> EJB Dao. I need to stick to this architecture due to some constraints within the organization.

So, in EJB Service Tx starts, I direct to a POJO which returns the local EJB DAO. Now within the methods of the EJB DAO, I inject the persistence context and the Entity Manager and the methods have been annotated with TransactionAttribute (Required). So my question is if within the DAO EJB will the transaction context of the Service EJB be used or will it start a new transaction due to the POJO layer in between.

Any help would be appreciated.

Thanks..Vijay

1

1 Answers

1
votes

Since a transaction is started from the "EJB Service", it will be propagated to the "EJB DAO". The transaction is set as a kind of thread local (at least conceptually, I don't know how implementations do it). That is unless the POJO does anything like running the DAO in a newlly created thread (which -for manually created threads- is inappropriate for Java EE anyway).