This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes TransactionRequiredException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "TransactionRequiredException" Watch "TransactionRequiredException" New topic


Nikhil Jain
Ranch Hand

Joined: May 15, 2005
Posts: 385
Why does methods like merge, persist thrown transactionRequired Exception is method is invoked on a transaction-scoped persistence context?

Does this mean that, these methods can only be invoked on extended persistence context?

SCJP 1.4, SCWCD 1.4, SCBCD 1.5
Adam Tkaczyk

Joined: Nov 29, 2007
Posts: 21
That is not true. Those methods trown TransactionRequiredException only when no transaction is available. The default transaction attribute for container managed ejb beans is REQUIRED. If you use merge, persist within transaction everything will be fine. Maybe you have set transaction attribute on business method wich invoke merge, persist to : NEVER , NOT_SUPPORTED or SUPPORTS. In this case container will not create transaction context and exception may be thrown.

I suggest you to read JSR 220 specification for further informations.
"EJB Core Contracts and Requirements" pages from 343 to 345

I agree. Here's the link:
subject: TransactionRequiredException
Similar Threads
TransactionRequiredException in Entities
find and getReference methods
[SCBCD] quick question on flush()
EJB 3.0 from O'Reilly
question about application-managed Entity manager