mirror of https://github.com/apache/openjpa.git
OPENJPA-203.
git-svn-id: https://svn.apache.org/repos/asf/incubator/openjpa/trunk@525950 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
80f7795fef
commit
e541936463
|
@ -86,7 +86,7 @@ public class PessimisticLockManager
|
|||
setLockLevel(sm, LOCK_DATASTORE_ONLY);
|
||||
}
|
||||
|
||||
protected void lockInternal(OpenJPAStateManager sm, int level, int timeout,
|
||||
protected void lockInternal(OpenJPAStateManager sm, int level, long timeout,
|
||||
Object sdata) {
|
||||
// we can skip any already-locked instance regardless of level because
|
||||
// we treat all locks the same (though super doesn't)
|
||||
|
@ -103,7 +103,7 @@ public class PessimisticLockManager
|
|||
* Lock the specified instance row by issuing a "SELECT ... FOR UPDATE"
|
||||
* statement.
|
||||
*/
|
||||
private void lockRow(OpenJPAStateManager sm, int timeout) {
|
||||
private void lockRow(OpenJPAStateManager sm, long timeout) {
|
||||
// assert that the dictionary supports the "SELECT ... FOR UPDATE"
|
||||
// construct; if not, and we the assertion does not throw an
|
||||
// exception, then just return without locking
|
||||
|
@ -136,7 +136,7 @@ public class PessimisticLockManager
|
|||
if (log.isWarnEnabled())
|
||||
log.warn(_loc.get("millis-query-timeout"));
|
||||
}
|
||||
stmnt.setQueryTimeout(timeout / 1000);
|
||||
stmnt.setQueryTimeout((int) (timeout / 1000));
|
||||
}
|
||||
rs = stmnt.executeQuery();
|
||||
if (!rs.next())
|
||||
|
|
|
@ -69,17 +69,15 @@ public class VersionLockManager
|
|||
return;
|
||||
while (sm.getOwner() != null)
|
||||
sm = sm.getOwner();
|
||||
int oldlevel = getLockLevel(sm);
|
||||
if (!sm.isPersistent() || sm.isNew() || level <= oldlevel)
|
||||
int oldLevel = getLockLevel(sm);
|
||||
if (!sm.isPersistent() || sm.isNew() || level <= oldLevel)
|
||||
return;
|
||||
|
||||
// set the lock level first to avoid infinite recursion
|
||||
setLockLevel(sm, level);
|
||||
try {
|
||||
lockInternal(sm, level, timeout, sdata);
|
||||
} catch (RuntimeException re) {
|
||||
// revert lock
|
||||
setLockLevel(sm, oldlevel);
|
||||
setLockLevel(sm, oldLevel);
|
||||
throw re;
|
||||
}
|
||||
}
|
||||
|
@ -94,6 +92,9 @@ public class VersionLockManager
|
|||
*/
|
||||
protected void lockInternal(OpenJPAStateManager sm, int level, long timeout,
|
||||
Object sdata) {
|
||||
// Set lock level first to prevent infinite recursion with
|
||||
// transactional(..) call
|
||||
setLockLevel(sm, level);
|
||||
if (level >= LockLevels.LOCK_WRITE && _versionUpdateOnWriteLock)
|
||||
getContext().transactional(sm.getManagedInstance(), true, null);
|
||||
else if (level >= LockLevels.LOCK_READ && _versionCheckOnReadLock)
|
||||
|
@ -132,6 +133,5 @@ public class VersionLockManager
|
|||
*/
|
||||
public boolean getVersionUpdateOnWriteLock() {
|
||||
return _versionUpdateOnWriteLock;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue