aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes Transaction Management Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Transaction Management" Watch "Transaction Management" New topic
Author

Transaction Management

vShyam Sundar
Ranch Hand

Joined: Oct 13, 2010
Posts: 60
Hi all,

I am very much confused with transaction at service/application layer and transaction at DAO layer.
My question is What is the purpose of a transaction at a service layer?

Lets say for Example. I have shopping cart where the requirement says on successful payment of fee

1) the order information Should be sent to the shipping sector
2)Removing an item from the cart
3)Sending an email to the customer who ordered it

The basic principle is to put all the three under a single transaction. SO either all commits or rollbacks. but what confuses me is

Where to start this transaction, Should i start this transaction at Service layer in session beans or at the dao layer with entity beans?

With EJB, If i start my transaction at the service layer containing session beans, this can be propagated to entity beans so either all commits are roll backs, if some failure occurs

but what happens if i integrate my application with Hibernate instead of entity beans for persistence,Now I am aware that hibernate transaction should be used for

persistence instead of EJB transaction.

my question is in this scenario what is the purpose of starting a transaction in session bean when we use hibernate transaction.


Thanks,
Shyam.
Arun Kumarr
Ranch Hand

Joined: May 16, 2005
Posts: 513

"I am very much confused with transaction at service/application layer and transaction at DAO layer."
-- While understanding transactions, you need to understand what is a resource manager? types of transactions --> RMLT, Global transaction, Sessions, Unit of Work (specifically what is the difference between transactional Unit of Work, Hibernate Unit of Work, etc.,), transaction demarcation mechanisms.

"My question is What is the purpose of a transaction at a service layer? "
-- Because you service can be spread across multiple Resource Managers (Database being one!!)

My quick suggestion is to read a nice book. Especially the sections related to transactions in EJB, Hibernate.
Further if you are interested, you can read about spring transaction.

"my question is in this scenario what is the purpose of starting a transaction in session bean when we use hibernate transaction. "
-- Read about RMLT, CMT, BMT. Googling would give you some nice documents.


If you are not laughing at yourself, then you just didn't get the joke.
vShyam Sundar
Ranch Hand

Joined: Oct 13, 2010
Posts: 60
Thanks Arun
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Transaction Management