*
The moose likes Object Relational Mapping and the fly likes Best way of Using Transaction Support Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Best way of Using Transaction Support" Watch "Best way of Using Transaction Support" New topic
Author

Best way of Using Transaction Support

Ravi Kiran Va
Ranch Hand

Joined: Apr 18, 2009
Posts: 2234

Hi ,

Please tell tme know what is the best way if one needs a Transaction Support :

For example if my requiremnet is to persist the User Submitted Data into the DataBase .

1. Shall i use TransactionAttribute(Required) on the BusinessService Method ??

Or

2. should i use EntityManager Transaction Suppourt

em.getTransaction().begin();

createEmployee("Ravi","Kiran",15000);

em.getTransaction().commit();


Please let me know what is the best choice ??

Save India From Corruption - Anna Hazare.
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

I don't normally drink beer, but when I do. I prefer Dos XX.

Sorry, I prefer using a Transaction manager and not use .beginTransaction() commit() and rollback() because I get to put my transaction demarkation at the best level/tier that it should be set at. The service layer. My Use Cases are what I need transactional, the whole Use Case, and be done when the use case finishes. Since the Service Layer is where I start and stop my use cases, it is the perfect candidate to demark my transaction boundaries.

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Ravi Kiran Va
Ranch Hand

Joined: Apr 18, 2009
Posts: 2234

Thank you Mark . I also planned to use Method level transactions .

I don't normally drink beer, but when I do. I prefer Dos XX.
but what is this line ?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Best way of Using Transaction Support
 
Similar Threads
Unable to catch StaleObjectStateException. EJB exception doesn't wrap it.
EntityTransaction.begin(); and EntityTransaction.commit();
With respect to using CMT Transactions in SessionBeans and Hibernate
Getting transaction
RMI and Transactions