File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "transaction rollback during multiple session" Watch "transaction rollback during multiple session" New topic

transaction rollback during multiple session

Abubacker Siddik
Ranch Hand

Joined: Aug 12, 2009
Posts: 90
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.
Abubacker Siddik
Ranch Hand

Joined: Aug 12, 2009
Posts: 90

Any help guys..
I agree. Here's the link:
subject: transaction rollback during multiple session
It's not a secret anymore!