• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Tim Cooke
Sheriffs:
  • Rob Spoor
  • Liutauras Vilda
  • paul wheaton
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
  • Piet Souris
Bartenders:
  • Stephan van Hulst

Transaction Management

 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 662
Eclipse IDE Spring Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"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.
 
vShyam Sundar
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Arun
 
Hold that thought. Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic