Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

Best way of Using Transaction Support

 
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ??
 
ranger
Posts: 17346
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ?
 
Oh sure, it's a tiny ad, but under the right circumstances, it gets bigger.
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic