Setting a timeout for a session or transaction in sleep mode

Below is my scenario: My application starts a transaction, inserts / updates, and then calls the web service. It is likely that the web service will take a long time to process the request. Is there a way to set a timeout for my session / transaction at my sleeping level so that I can gracefully close the session. Postscript - In addition, I can also see how to set a timeout for my web service call. Assume that I do not have such freedom. Is there anything I can do in Hibernate, or do I need to write my own logic (using join join constructs) to implement these

+3
source share
1 answer

You can set a timeout at the specific request level or if you use JPA EntityManager you can add a hint .

The theory is that Hibernate uses optimistic locking by default (if the database transaction isolation level matches this), so records are never locked again, writing or reading. As a result, even a long transaction should not greatly degrade performance.

If you are using Psimic Lock, you can set a timeout for them in a Hibernate session. Take a look at Session.LockRequest .

+3
source

All Articles