idrak_07
idrak_07

Reputation: 29

How to unlock @Lock(LockModeType.PESSIMISTIC_WRITE) if there is no transaction

I have put @Lock(LockModeType.PESSIMISTIC_WRITE) on a query and working on it in service layer with @Transactionsal annotation. The lock is acquired successfully. But for some cases, the transaction could not be happened. And this lock takes time to be released. My concern is how can I release the lock immediately ?

Upvotes: 0

Views: 2527

Answers (1)

Ali Naser Khan
Ali Naser Khan

Reputation: 26

You can explicitly unlock by

entityManager.lock(entityObject, LockModeType.NONE);

Upvotes: 1

Related Questions