This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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 Murach's Java Servlets and JSP this week in the Servlets 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: 9345
    
    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: 9345
    
    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.

 
It is sorta covered in the JavaRanch Style Guide.
 
subject: TransactionRequiredException in Entities
 
Similar Threads
error in HF EJB and not listed in the erata
page 551 of the HF EJB
Doubt in BMT
Method / Bean Transaction (warning: HFE Master Mock Exam Question)
Exception handling in EJB with Container Managed Transaction using Hibernate