File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes TransactionRequiredException in Entities Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "TransactionRequiredException in Entities" Watch "TransactionRequiredException in Entities" New topic
Author

TransactionRequiredException in Entities

Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9466
    
    2

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?


SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!
Treimin Clark
Ranch Hand

Joined: Nov 12, 2008
Posts: 757
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

Joined: Sep 26, 2006
Posts: 9466
    
    2

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.

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: TransactionRequiredException in Entities