Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

EJB transaction propogation to Simple Java Objects (SJO)  RSS feed

 
Raj CK
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
StateLessSB1(ContainerManaged Tx)

StateLessSB1.persistData()
|
|
|------> JavaObject1.storeData(){doSomeDbXXXOperation()}
|
|------> JavaObject2.updateData(){doSomeDbYYYOperation()}
|
|
| if (txNotMarkedForRollBack){
| some more database operations
| }
|
|

Given above scenario--

1) Will the trasaction started at 'StateLessSB1.persistData()' will propogate to simple java objects JavaObject1 and JavaObject2?

2) If answer is yes, how do we mark transaction for rollback (without using exception feedback)?
 
Roger Chung-Wee
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. Yes

2. Invoke EJBContext.setRollbackOnly(). A typical use is to catch an application exception in a certain point in your code because it is pointless to continue with the transaction. So, you invoke setRollbackOnly() and rethrow the Application Exception (in that order).

You then invoke EJBContext.getRollbackOnly() to determine whether to continue processing.

At the end of the business method, the container will ensure that the transaction is rolled back. If an application exception is thrown, the container will then pass the exception to the client.
 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 36406
454
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"JavaWorkz",
We're pleased to have you here with us in the J2EE forum, but there are a few rules that need to be followed, and one is that proper names are required. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

Note that we recently lost some data. So if you already changed your display name, we'd appreciate your doing it again.

Thanks,
Jeanne
Forum Bartender
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!