Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Pessimistice locking hint - hanging locks
Pessimistice locking hint - hanging locks [message #479759] Wed, 12 August 2009 12:25 Go to next message
Tom Eugelink is currently offline Tom EugelinkFriend
Messages: 817
Registered: July 2009
Senior Member
It is possible to place locks during querying using the Eclipselink JPA enhancement "pessimistic lock hint".
http://blogs.sun.com/enterprisetechtips/entry/preventing_non _repeatable_reads_in

When you do this without having started the EM's transaction, Eclipselink starts a JDBC transaction to the database and does a select-for-update instead of a regular select.
The JDBC transaction is required, because that determines how long locks are held; upon commit or rollback and "for update" locks are released.

However, the EM's transaction is not started (getTransaction().isActive() returns false), so if you do not start the EM's transaction, the locks are never released.

Is there any way to release these for-update locks without starting the EM's transaction?
Re: Pessimistice locking hint - hanging locks [message #480834 is a reply to message #479759] Tue, 18 August 2009 15:29 Go to previous message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

You should never acquire a pessimistic lock outside of a transaction.
Always first call beginTransaction. You can log a bug that an exception
should be throw if pessimistic locking is attempted outside of a
transaction.

----
James


James : Wiki : Book : Blog : Twitter
Previous Topic:loader constraint violation
Next Topic:Cache Refresh Problem
Goto Forum:
  


Current Time: Thu Mar 28 20:04:09 GMT 2024

Powered by FUDForum. Page generated in 0.02721 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top