• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

EJB transaction propogation to Simple Java Objects (SJO)

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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)?
 
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
author & internet detective
Posts: 41907
909
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic