Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / November 2007

Tip: Looking for answers? Try searching our database.

EJB 3.0 Transaction Propagation and POJO

Thread view: 
Dhananjay - 05 Nov 2007 10:09 GMT
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
Owen Jacobson - 05 Nov 2007 18:21 GMT
> Hi,
>
[quoted text clipped - 15 lines]
> 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".


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.