openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ss...@apache.org
Subject svn commit: r525950 - in /incubator/openjpa/trunk: openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/PessimisticLockManager.java openjpa-kernel/src/main/java/org/apache/openjpa/kernel/VersionLockManager.java
Date Thu, 05 Apr 2007 20:06:27 GMT
Author: ssegu
Date: Thu Apr  5 13:06:24 2007
New Revision: 525950

URL: http://svn.apache.org/viewvc?view=rev&rev=525950
Log:
OPENJPA-203.

Modified:
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/PessimisticLockManager.java
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/VersionLockManager.java

Modified: incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/PessimisticLockManager.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/PessimisticLockManager.java?view=diff&rev=525950&r1=525949&r2=525950
==============================================================================
--- incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/PessimisticLockManager.java
(original)
+++ incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/PessimisticLockManager.java
Thu Apr  5 13:06:24 2007
@@ -86,7 +86,7 @@
             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 @@
      * 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 @@
                     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())

Modified: incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/VersionLockManager.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/VersionLockManager.java?view=diff&rev=525950&r1=525949&r2=525950
==============================================================================
--- incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/VersionLockManager.java
(original)
+++ incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/VersionLockManager.java
Thu Apr  5 13:06:24 2007
@@ -69,17 +69,15 @@
             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 @@
      */
     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 boolean getVersionUpdateOnWriteLock() {
         return _versionUpdateOnWriteLock;
-	}
+    }
 }
-



Mime
View raw message