openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hthom...@apache.org
Subject svn commit: r1539193 - in /openjpa/branches/2.2.1.x: ./ openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/PessimisticLockManager.java openjpa-kernel/src/main/java/org/apache/openjpa/kernel/StateManagerImpl.java
Date Tue, 05 Nov 2013 23:25:38 GMT
Author: hthomann
Date: Tue Nov  5 23:25:38 2013
New Revision: 1539193

URL: http://svn.apache.org/r1539193
Log:
OPENJPA-2449: refresh(PESSIMISTIC_WRITE) generates seperate SQL for the lock - applied to
2.2.1.x Albert Lee's patch.

Modified:
    openjpa/branches/2.2.1.x/   (props changed)
    openjpa/branches/2.2.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/PessimisticLockManager.java
    openjpa/branches/2.2.1.x/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/StateManagerImpl.java

Propchange: openjpa/branches/2.2.1.x/
------------------------------------------------------------------------------
  Merged /openjpa/branches/2.1.x:r1539188

Modified: openjpa/branches/2.2.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/PessimisticLockManager.java
URL: http://svn.apache.org/viewvc/openjpa/branches/2.2.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/PessimisticLockManager.java?rev=1539193&r1=1539192&r2=1539193&view=diff
==============================================================================
--- openjpa/branches/2.2.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/PessimisticLockManager.java
(original)
+++ openjpa/branches/2.2.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/PessimisticLockManager.java
Tue Nov  5 23:25:38 2013
@@ -101,13 +101,12 @@ public class PessimisticLockManager
     protected void lockInternal(OpenJPAStateManager sm, int level, int timeout,
         Object sdata, boolean postVersionCheck) {
         // we can skip any already-locked instance regardless of level because
-        // we treat all locks the same (though super doesn't)
-        if (getLockLevel(sm) == LOCK_NONE) {
-            // only need to lock if not loaded from locking result
-            ConnectionInfo info = (ConnectionInfo) sdata;
-            if (info == null || info.result == null || !info.result.isLocking())
-                lockRow(sm, timeout, level);
-        }
+        // we treat all locks the same (though super doesn't).
+        
+        // only need to lock if not loaded from locking result
+        ConnectionInfo info = (ConnectionInfo) sdata;
+        if (info == null || info.result == null || !info.result.isLocking())
+            lockRow(sm, timeout, level);
         optimisticLockInternal(sm, level, timeout, sdata, postVersionCheck);
     }
 
@@ -128,7 +127,9 @@ public class PessimisticLockManager
         Object id = sm.getObjectId();
         ClassMapping mapping = (ClassMapping) sm.getMetaData();
 
-        List<SQLBuffer> sqls = getLockRows(dict, id, mapping, fetch, _store.getSQLFactory());

+        List<SQLBuffer> sqls = sm.getLock() == null
+            ?  getLockRows(dict, id, mapping, fetch, _store.getSQLFactory())
+            : new ArrayList<SQLBuffer>();
         if (ctx.getFetchConfiguration().getLockScope() == LockScopes.LOCKSCOPE_EXTENDED)
             lockJoinTables(sqls, dict, id, mapping, fetch, _store.getSQLFactory());
 

Modified: openjpa/branches/2.2.1.x/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/StateManagerImpl.java
URL: http://svn.apache.org/viewvc/openjpa/branches/2.2.1.x/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/StateManagerImpl.java?rev=1539193&r1=1539192&r2=1539193&view=diff
==============================================================================
--- openjpa/branches/2.2.1.x/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/StateManagerImpl.java
(original)
+++ openjpa/branches/2.2.1.x/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/StateManagerImpl.java
Tue Nov  5 23:25:38 2013
@@ -1386,9 +1386,9 @@ public class StateManagerImpl
         if (fetch == null)
             fetch = _broker.getFetchConfiguration();
 
-        if (_readLockLevel == -1)
+        if (_readLockLevel == -1 || _readLockLevel < fetch.getReadLockLevel())
             _readLockLevel = fetch.getReadLockLevel();
-        if (_writeLockLevel == -1)
+        if (_writeLockLevel == -1 || _writeLockLevel < fetch.getWriteLockLevel())
             _writeLockLevel = fetch.getWriteLockLevel();
         return (forWrite) ? _writeLockLevel : _readLockLevel;
     }



Mime
View raw message