This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes EJB and other Java EE Technologies and the fly likes Urgent transaction question! Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Reply Bookmark "Urgent transaction question!" Watch "Urgent transaction question!" New topic
Author

Urgent transaction question!

rose deng
Ranch Hand

Joined: Dec 29, 2000
Posts: 78
Hi,
In my project, i have a sessionbeanA, it has methodA(). In methodA(), i call classB's methodB(). In methodB(), I first call classC's methodC() and then classD's methodD(). In methodC() will call entitybeanE's methodE(); in methodD() will call entitybeanF's methodF(). methodE() will insert record to table1, and methodF() will insert record to table2.
What i want: when exception happen in classD's methodD(), inserted record in table1 will rollback.
What i do:
1. Transaction is container managed transaction.
2. Set transaction attribute for sessinbeanA,entitybeanE,entitybeanF as 'Required'.
3. Exception in methodD(), will be finally caught in sessionbeanA's methodA(). code in methodA() is as following:
try
{
bla bla
}
catch(AppException ex)
{
sessionContext.setRollbackOnly();
}
What i get: inserted record in table1 is still there, not rollback.
What's wrong?? Any correction is highly appreciated.
Manas Ahlaad
Ranch Hand

Joined: Nov 07, 2001
Posts: 165
can you please make it clear. give more info. code will help ....
 
I agree. Here's the link: jrebel
 
subject: Urgent transaction question!
 
Similar Threads
method override question
jdiscuss question
Why not rollback???
Limit on # of Methods?
interesting issue