Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

transaction in EJB 2

 
Raj Ohadi
Ranch Hand
Posts: 316
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Suppose i want to do something like updating few hundred records using my DAO class. I want a whole or nothing scenario -- either updating all or none.

1. If I do not use any EJB, what transaction method shall I use ? Can I use JTA ?

2. If I use a stateless session bean (EJB 2) for this action, how do I handle the transaction ? Shall I specify the transaction in config file ? If I specify it in config file, can I specify the transaction 'block' instead of a method ? i.e how do I ensure a small code block is in a transaction ? any example ?

Thanks.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

1. If I do not use any EJB, what transaction method shall I use ? Can I use JTA ?

If you like. Or a JDBC transaction would do.


2. If I use a stateless session bean (EJB 2) for this action, how do I handle the transaction ? Shall I specify the transaction in config file ? If I specify it in config file, can I specify the transaction 'block' instead of a method ? i.e how do I ensure a small code block is in a transaction ? any example ?

Your transaction demarcation is at the method level. You would need to write an EJB method to perform your update.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic