• 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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Need help with Transaction settings in WSAD 5

 
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Could somebody help me with setting transaction attributes in WSAD 5.0?
I cannot make them working.
I have a method addAssgn() in the session bean, where I insert into three tables.
To insert into first table I use create(...) method of BMP entity bean and
I insert into two others tables in this Session bean using datasource look up.
In Deployment descriptor on Bean tab I've set transaction type to 'container'
and on Assembly descriptor tab I've set container transaction type to 'required'
for that method. Looks like I missed something, because when
inserting into second table failed, it doesn't rollback
(I have data in the first table inserted)
Thanks
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
You need to handle the exceptions in your session bean method...
Put the code in try block and catch Throwable or Exception and call setRollbackOnly() method on the SessionContext object. So whenever there is an exception, your container knows to rollback or commit them as whole...
public method()
{
try{
//call other bean methods here...
}
catch(Throwable t)
{
//mark the transaction to rollback...
getSessionContext().setRollbackOnly();
}
}
Hope this works fine...
Thanks,
Malar.
 
Jenny Kalinina
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Malar. Now it works well
 
Now I am super curious what sports would be like if we allowed drugs and tiny ads.
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic