This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Object Relational Mapping and the fly likes transaction rollback during multiple session Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "transaction rollback during multiple session" Watch "transaction rollback during multiple session" New topic
Author

transaction rollback during multiple session

Abubacker Siddik
Ranch Hand

Joined: Aug 12, 2009
Posts: 90
Hi
I am trying to write a framework class which can be used by our applications. This class provides methods to create hibernate session and ways to commit and rollback the transaction. I have designed in such a way that there will be always two methods to do commit, rollback and creating sessions. To put it clearly, to create session, one method will give default session by calling openSession on SessionFactory, second method will get a parameter from the user to create new session rather than to return session created by default. Likewise to commit, i will have commit method which will commit default session transaction, but for second commit method, i will get parameter that will accept session object and commit on that particular session. Same applies to rollback method also.

My question is, When user gets session and works on it, an exception occurs that will be caught by my framework class. Now how will i identify which session the user was using and which transaction should i rollback in my catch block? It can be default session or new session created by the customized method. How to know the origin of the exception or from which session the exception was thrown?


Kindly help me guys..


Thanks in Advance.
Abu.A
Abubacker Siddik
Ranch Hand

Joined: Aug 12, 2009
Posts: 90

Any help guys..
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: transaction rollback during multiple session