Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

TransactionRequiredException in Entities

 
Joe Harry
Ranch Hand
Posts: 10128
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Guys,

The information given in the EJB 3 book from O'Reilly on page 80 says that the TransactionRequiredException is thrown when the method that does either update, merge operation on an Entity is called on a transaction-scoped persistence context. I guess it should be the opposite way. Is this an errata in the book?
 
Treimin Clark
Ranch Hand
Posts: 757
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jothi Shankar Kumar wrote:Guys,

The information given in the EJB 3 book from O'Reilly on page 80 says that the TransactionRequiredException is thrown when the method that does either update, merge operation on an Entity is called on a transaction-scoped persistence context. I guess it should be the opposite way. Is this an errata in the book?


I think it is not an errata. When invoked those methods on an EntityManager with transaction-scoped persistence context, without having a transaction (EntityTransaction.begin() method), it will throw the TransactionRequiredException.

Read the documentation.


Please correct me, if I'm wrong.
 
Joe Harry
Ranch Hand
Posts: 10128
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The example in the book has a method that has a transaction scoped persistence context followed by this line as posted above which is quite contradictory.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic