Using Hibernate 2.1.8 with Weblogic 8.1 and Oracle 9i, configured with JTATransactionFactory and WeblogicTransactionManagerLookup.
I have been all over the forums and internet and cannot seem to find information about the following situation.
I have a long running process that runs 30 seconds to a few minutes in a web application. It is required that only one user be allowed to run this at any one time. To ensure this, what I would like to do is keep a flag in a specified record in an Oracle database which would be set to Y with Hibernate when a user is using the function, and be set to N when finished. This would block out any other users from using the function at the same time an function as a lock. (The web application is clustered so a synchronized block would not work.)
The problem is my application uses JTA XA Global Transactions using Weblogic. The transaction begins when the request begins and does not commit until the request is finished. So even if I set the flag to Y at the beginning of the process, no other process will see the change until the process is done. Even if I try to commit the hibernate transaction explicitly it does not work, and results in an exception saying that one transaction cannot be committed multiple times.
I also tried to get the weblogic TransactionManager explicitly and call suspend() and resume(), with beginning and committing the new transaction created in between. This did not work either, as it seems even this new transaction was really part of the global transaction. (Also, this would have required going around Hibernate's wrapper abstraction for transactions, which is probably not the best thing to do)
So, I am at a loss how this can be accomplished, if it can be at all. Anyone know how to do this, or offer an alternative?
Thank you,
Daniel
|