• 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
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

I want to Rollback a transaction

 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi friends,
i have an stateless session bean, in that i have business method which removes all the entity beans related to a particular ID, but before deleting each entity i peform a validation, if that fails i want to roll back all the records which were deleted prior to the last failed validation
can you please tell me the better way of rolling back all the record
the two ways i know is
1. ebjcontext.setrollbackonly and
2. throwing a new system exception
can somebody guide me how to handle this situation for rolling back.
Thanks in Advace
Ravi.I
[ January 24, 2003: Message edited by: ravi inguva ]
 
Ranch Hand
Posts: 2713
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by ravi inguva:

can you please tell me the better way of rolling back all the records
the two ways i know is
1. ebjcontext.setrollbackonly and
2. throwing a new system exception
can somebody guide me how to handle this situation for rolling back.


That's it. What is it that you find inadequate about either of those choices for rolling back a transaction?
Of course, for the rollback to work the way you intend, the transactional attributes will need to be properly set on your Entity Beans. In other words, all of your Entity Bean interaction needs to take place in the context of the same transaction.
In this case you should mark your Entity Beans with the transactional attribute "Required" and mark your Session Bean with "RequiresNew". In general I usually mark Entity Beans as "Required" unless they are Read-Only in which case I mark them as "NotSupported".
If properly configured, you should only have to rollback from your Session Bean in order to rollback all the Entity Bean interactions.
 
Paddy spent all of his days in the O'Furniture back yard with this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic