Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Best way of Using Transaction Support

 
Ravi Kiran Va
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 ??
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac 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 ?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic