openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fayw...@apache.org
Subject svn commit: r1032686 - in /openjpa/trunk: openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/PessimisticLockManager.java openjpa-persistence/src/main/java/org/apache/openjpa/persistence/EntityManagerImpl.java
Date Mon, 08 Nov 2010 20:10:46 GMT
Author: faywang
Date: Mon Nov  8 20:10:45 2010
New Revision: 1032686

URL: http://svn.apache.org/viewvc?rev=1032686&view=rev
Log:
OPENJPA-1762: lock join table when pessimistic scope is set to EXTENDED

Modified:
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/PessimisticLockManager.java
    openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/EntityManagerImpl.java

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/PessimisticLockManager.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/PessimisticLockManager.java?rev=1032686&r1=1032685&r2=1032686&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/PessimisticLockManager.java
(original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/PessimisticLockManager.java
Mon Nov  8 20:10:45 2010
@@ -34,6 +34,7 @@ import org.apache.openjpa.jdbc.sql.DBDic
 import org.apache.openjpa.jdbc.sql.SQLBuffer;
 import org.apache.openjpa.jdbc.sql.SQLFactory;
 import org.apache.openjpa.jdbc.sql.Select;
+import org.apache.openjpa.kernel.LockScopes;
 import org.apache.openjpa.kernel.MixedLockLevels;
 import org.apache.openjpa.kernel.OpenJPAStateManager;
 import org.apache.openjpa.kernel.StoreContext;
@@ -128,7 +129,8 @@ public class PessimisticLockManager
         ClassMapping mapping = (ClassMapping) sm.getMetaData();
 
         List<SQLBuffer> sqls = getLockRows(dict, id, mapping, fetch, _store.getSQLFactory());

-        lockJoinTables(sqls, dict, id, mapping, fetch, _store.getSQLFactory());
+        if (ctx.getFetchConfiguration().getLockScope() == LockScopes.LOCKSCOPE_EXTENDED)
+            lockJoinTables(sqls, dict, id, mapping, fetch, _store.getSQLFactory());
 
         ensureStoreManagerTransaction();
         Connection conn = _store.getConnection();

Modified: openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/EntityManagerImpl.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/EntityManagerImpl.java?rev=1032686&r1=1032685&r2=1032686&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/EntityManagerImpl.java
(original)
+++ openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/EntityManagerImpl.java
Mon Nov  8 20:10:45 2010
@@ -43,6 +43,7 @@ import javax.persistence.CacheStoreMode;
 import javax.persistence.EntityManager;
 import javax.persistence.FlushModeType;
 import javax.persistence.LockModeType;
+import javax.persistence.PessimisticLockScope;
 import javax.persistence.Query;
 import javax.persistence.TypedQuery;
 import javax.persistence.criteria.CriteriaQuery;
@@ -1682,8 +1683,14 @@ public class EntityManagerImpl
             LockModeType lock, boolean requiresTxn) {
         // handle properties in map first
         if (properties != null) {
-            for (Map.Entry<String, Object> entry : properties.entrySet())
-                fetch.setHint(entry.getKey(), entry.getValue());
+            for (Map.Entry<String, Object> entry : properties.entrySet()) {
+                String key = entry.getKey();
+                Object value = entry.getValue();
+                if (key.equals("javax.persistence.lock.scope")) {
+                    fetch.setLockScope((PessimisticLockScope)value);
+                } else
+                    fetch.setHint(key, value);
+            }
         }
         // override with the specific lockMode, if needed.
         if (lock != null && lock != LockModeType.NONE) {



Mime
View raw message