openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From allee8...@apache.org
Subject svn commit: r762409 - in /openjpa/trunk: openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/ openjpa-kernel/src/main/java/org/apache/openjpa/kernel/ openjpa-kernel/src/main/resources/org/apache/openjpa/kernel/ openjpa-persistence-jdbc/src/test/j...
Date Mon, 06 Apr 2009 16:30:25 GMT
Author: allee8285
Date: Mon Apr  6 16:30:24 2009
New Revision: 762409

URL: http://svn.apache.org/viewvc?rev=762409&view=rev
Log:
OPENJPA-1022 - Ensure LockMode READ/OPTIMISTIC & WRITE/OPTIMISTIC_FORCE_INCREMENT are distinct in type but semantics equivalent.

Modified:
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/MixedLockManager.java
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/FetchConfigurationImpl.java
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/MixedLockLevels.java
    openjpa/trunk/openjpa-kernel/src/main/resources/org/apache/openjpa/kernel/localizer.properties
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/lockmgr/SequencedActionsTest.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/lockmgr/TestFetchHints.java
    openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/FetchPlanHintHandler.java
    openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/MixedLockLevelsHelper.java
    openjpa/trunk/openjpa-persistence/src/main/resources/org/apache/openjpa/persistence/localizer.properties

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/MixedLockManager.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/MixedLockManager.java?rev=762409&r1=762408&r2=762409&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/MixedLockManager.java (original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/MixedLockManager.java Mon Apr  6 16:30:24 2009
@@ -66,7 +66,7 @@
             setVersionCheckOnReadLock(true);
             setVersionUpdateOnWriteLock(false);
             super.lockInternal(sm, level, timeout, sdata, postLockVersionCheck);
-        } else if (level >= MixedLockLevels.LOCK_OPTIMISTIC) {
+        } else if (level >= MixedLockLevels.LOCK_READ) {
             setVersionCheckOnReadLock(true);
             setVersionUpdateOnWriteLock(true);
             optimisticLockInternal(sm, level, timeout, sdata,

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/FetchConfigurationImpl.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/FetchConfigurationImpl.java?rev=762409&r1=762408&r2=762409&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/FetchConfigurationImpl.java (original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/FetchConfigurationImpl.java Mon Apr  6 16:30:24 2009
@@ -483,7 +483,9 @@
 
         if (level != DEFAULT
             && level != MixedLockLevels.LOCK_NONE
+            && level != MixedLockLevels.LOCK_READ
             && level != MixedLockLevels.LOCK_OPTIMISTIC
+            && level != MixedLockLevels.LOCK_WRITE
             && level != MixedLockLevels.LOCK_OPTIMISTIC_FORCE_INCREMENT
             && level != MixedLockLevels.LOCK_PESSIMISTIC_READ
             && level != MixedLockLevels.LOCK_PESSIMISTIC_WRITE
@@ -525,7 +527,9 @@
 
         if (level != DEFAULT
             && level != MixedLockLevels.LOCK_NONE
+            && level != MixedLockLevels.LOCK_READ
             && level != MixedLockLevels.LOCK_OPTIMISTIC
+            && level != MixedLockLevels.LOCK_WRITE
             && level != MixedLockLevels.LOCK_OPTIMISTIC_FORCE_INCREMENT
             && level != MixedLockLevels.LOCK_PESSIMISTIC_READ
             && level != MixedLockLevels.LOCK_PESSIMISTIC_WRITE

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/MixedLockLevels.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/MixedLockLevels.java?rev=762409&r1=762408&r2=762409&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/MixedLockLevels.java (original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/MixedLockLevels.java Mon Apr  6 16:30:24 2009
@@ -27,16 +27,16 @@
 public interface MixedLockLevels extends LockLevels {
 
     /**
-     * Generic optimistic read lock level. Value of 10.
+     * Generic optimistic read lock level. Value of 15.
      *
      */
-    public static final int LOCK_OPTIMISTIC = LOCK_READ;
+    public static final int LOCK_OPTIMISTIC = LOCK_READ + 5;
 
     /**
-     * Generic optimistic write lock level. Value of 20.
+     * Generic optimistic write lock level. Value of 25.
      */
     public static final int LOCK_OPTIMISTIC_FORCE_INCREMENT =
-        LockLevels.LOCK_WRITE;
+        LockLevels.LOCK_WRITE + 5;
 
     /**
      * Generic pessimistic read lock level. Value of 30.

Modified: openjpa/trunk/openjpa-kernel/src/main/resources/org/apache/openjpa/kernel/localizer.properties
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/resources/org/apache/openjpa/kernel/localizer.properties?rev=762409&r1=762408&r2=762409&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/resources/org/apache/openjpa/kernel/localizer.properties (original)
+++ openjpa/trunk/openjpa-kernel/src/main/resources/org/apache/openjpa/kernel/localizer.properties Mon Apr  6 16:30:24 2009
@@ -413,7 +413,7 @@
 bad-flush-before-queries: Invalid flush before queries type. Valid values are \
 	"true"(0), "false"(1) or "with-connection"(2). Specified value: {0}.
 bad-lock-level: Invalid lock mode/level. Valid values are \
-    "none"(0), "read"(10), "write"(20), "optimistic"(10), \
-    "optimistic-force-increment"(20), "pessimistic-read"(30), \
+    "none"(0), "read"(10), "optimistic"(15), "write"(20), \
+    "optimistic-force-increment"(25), "pessimistic-read"(30), \
     "pessimistic-write"(40) or "pessimistic-force-increment"(50). \
     Specified value: {0}.

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/lockmgr/SequencedActionsTest.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/lockmgr/SequencedActionsTest.java?rev=762409&r1=762408&r2=762409&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/lockmgr/SequencedActionsTest.java (original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/lockmgr/SequencedActionsTest.java Mon Apr  6 16:30:24 2009
@@ -22,7 +22,6 @@
 import java.io.ByteArrayOutputStream;
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
-import java.io.PrintStream;
 import java.io.PrintWriter;
 import java.io.StringWriter;
 import java.util.ArrayList;
@@ -327,381 +326,381 @@
             curAction = (Act) args[0];
             log.trace("** Act=" + Arrays.toString(args));
             try {
-                    switch (curAction) {
-                    case CreateEm:
-                        em = emf.createEntityManager();
-                        break;
-                    case CloseEm:
-                        if (em != null && em.isOpen()) {
-                            em.close();
-                            em = null;
-                        }
-                        break;
-                    case Clear:
-                        em.clear();
-                        break;
-                    case Flush:
-                        em.flush();
-                        break;
-                    case Find:
-                        id = 1;
-                        if (args.length > 1) {
-                            id = (Integer)args[1];
-                        }
-                        employee = em.find(LockEmployee.class, id);
-                        log.trace("Employee=" + employee);
-                        if( employee != null ) {
-                            employees.put(id, employee);
-                        } else {
-                            employees.remove(id);
-                        }
-                        break;
-                    case FindWithLock:
-                        id = 1;
-                        if (args[1] != null) {
-                            id = (Integer)args[1];
-                        }
-                        lockMode = LockModeType.NONE;
-                        if (args[2] != null) {
-                            lockMode = (LockModeType)args[2];
-                        }
-                        Map<String, Object> findProps = buildPropsMap(args, 3);
-                        if (findProps != null) {
-                            employee = em.find(LockEmployee.class, id,
-                                lockMode, findProps);
-                        } else {
-                            employee = em
-                                .find(LockEmployee.class, id, lockMode);
-                        }
-                        log.trace("Employee=" + employee);
-                        if( employee != null ) {
-                            employees.put(id, employee);
-                        } else {
-                            employees.remove(id);
-                        }
-                        break;
-                    case FindObject:
-                        em.find((Class<?>)args[1], args[2],
-                            (LockModeType) args[3]);
-                        // log.trace("Employee=" + employee);
-                        break;
-                    case Persist:
-                        id = 1;
-                        if (args[1] != null) {
-                            id = (Integer)args[1];
-                        }
-                        String firstName = (String)args[2];
-                        employee = new LockEmployee();
-                        employee.setId(id);
-                        employee.setFirstName(firstName);
-                        log.trace("Employee=" + employee);
-                        em.persist(employee);
-                        break;
-                    case Remove:
-                        id = 1;
-                        if (args.length > 1) {
-                            id = (Integer)args[1];
-                        }
-                        employee = employees.get(id);
-                        log.trace("Employee=" + employee);
-                        em.remove(employee);
-                        break;
-                    case Refresh:
-                        id = 1;
-                        if (args.length > 1) {
-                            id = (Integer)args[1];
-                        }
-                        employee = employees.get(id);
-                        log.trace("Employee(before)=" + employee);
-                        em.refresh(employee);
-                        log.trace("Employee(after) =" + employee);
-                        break;
-                    case RefreshWithLock:
-                        id = 1;
-                        if (args[1] != null) {
-                            id = (Integer)args[1];
-                        }
-                        lockMode = LockModeType.NONE;
-                        if (args[2] != null) {
-                            lockMode = (LockModeType)args[2];
-                        }
-                        employee = employees.get(id);
-                        log.trace("Employee(before)=" + employee);
-                        Map<String, Object> refreshProps = buildPropsMap(args,
-                            3);
-                        if (refreshProps != null) {
-                            em.refresh(employee, lockMode, refreshProps);
-                        } else {
-                            em.refresh(employee, lockMode);
-                        }
-                        log.trace("Employee(after) =" + employee);
-                        break;
-                    case RefreshObject:
-                        em.refresh(args[1], (LockModeType) args[2]);
-                        break;
-                    case Lock:
-                        id = 1;
-                        if (args[1] != null) {
-                            id = (Integer)args[1];
-                        }
-                        lockMode = LockModeType.NONE;
-                        if (args[2] != null) {
-                            lockMode = (LockModeType)args[2];
-                        }
-                        employee = employees.get(id);
-                        log.trace("Employee=" + employee);
-                        Map<String, Object> lockProps = buildPropsMap(args, 3);
-                        if (lockProps != null) {
-                            em.lock(employee, lockMode, lockProps);
-                        } else {
-                            em.lock(employee, lockMode);
-                        }
-                        break;
-                    case LockObject:
-                        em.lock(args[1], (LockModeType) args[2]);
-                        break;
-                    case UpdateEmployee:
-                        id = 1;
-                        if (args.length > 1) {
-                            id = (Integer) args[1];
-                        }
-                        employee = employees.get(id);
-                        log.trace("Employee (before):" + employee);
-                        String newFirstName = "Unknown";
-                        if (args.length > 2) {
-                            newFirstName = (String) args[2];
-                        } else {
-                            newFirstName = (new Date()).toString();
-                        }
-                        employee.setFirstName(newFirstName);
-                        log.trace("Employee (after) :" + employee);
-                        break;
+                switch (curAction) {
+                case CreateEm:
+                    em = emf.createEntityManager();
+                    break;
+                case CloseEm:
+                    if (em != null && em.isOpen()) {
+                        em.close();
+                        em = null;
+                    }
+                    break;
+                case Clear:
+                    em.clear();
+                    break;
+                case Flush:
+                    em.flush();
+                    break;
+                case Find:
+                    id = 1;
+                    if (args.length > 1) {
+                        id = (Integer)args[1];
+                    }
+                    employee = em.find(LockEmployee.class, id);
+                    log.trace("Employee=" + employee);
+                    if( employee != null ) {
+                        employees.put(id, employee);
+                    } else {
+                        employees.remove(id);
+                    }
+                    break;
+                case FindWithLock:
+                    id = 1;
+                    if (args[1] != null) {
+                        id = (Integer)args[1];
+                    }
+                    lockMode = LockModeType.NONE;
+                    if (args[2] != null) {
+                        lockMode = (LockModeType)args[2];
+                    }
+                    Map<String, Object> findProps = buildPropsMap(args, 3);
+                    if (findProps != null) {
+                        employee = em.find(LockEmployee.class, id,
+                            lockMode, findProps);
+                    } else {
+                        employee = em
+                            .find(LockEmployee.class, id, lockMode);
+                    }
+                    log.trace("Employee=" + employee);
+                    if( employee != null ) {
+                        employees.put(id, employee);
+                    } else {
+                        employees.remove(id);
+                    }
+                    break;
+                case FindObject:
+                    em.find((Class<?>)args[1], args[2],
+                        (LockModeType) args[3]);
+                    // log.trace("Employee=" + employee);
+                    break;
+                case Persist:
+                    id = 1;
+                    if (args[1] != null) {
+                        id = (Integer)args[1];
+                    }
+                    String firstName = (String)args[2];
+                    employee = new LockEmployee();
+                    employee.setId(id);
+                    employee.setFirstName(firstName);
+                    log.trace("Employee=" + employee);
+                    em.persist(employee);
+                    break;
+                case Remove:
+                    id = 1;
+                    if (args.length > 1) {
+                        id = (Integer)args[1];
+                    }
+                    employee = employees.get(id);
+                    log.trace("Employee=" + employee);
+                    em.remove(employee);
+                    break;
+                case Refresh:
+                    id = 1;
+                    if (args.length > 1) {
+                        id = (Integer)args[1];
+                    }
+                    employee = employees.get(id);
+                    log.trace("Employee(before)=" + employee);
+                    em.refresh(employee);
+                    log.trace("Employee(after) =" + employee);
+                    break;
+                case RefreshWithLock:
+                    id = 1;
+                    if (args[1] != null) {
+                        id = (Integer)args[1];
+                    }
+                    lockMode = LockModeType.NONE;
+                    if (args[2] != null) {
+                        lockMode = (LockModeType)args[2];
+                    }
+                    employee = employees.get(id);
+                    log.trace("Employee(before)=" + employee);
+                    Map<String, Object> refreshProps = buildPropsMap(args,
+                        3);
+                    if (refreshProps != null) {
+                        em.refresh(employee, lockMode, refreshProps);
+                    } else {
+                        em.refresh(employee, lockMode);
+                    }
+                    log.trace("Employee(after) =" + employee);
+                    break;
+                case RefreshObject:
+                    em.refresh(args[1], (LockModeType) args[2]);
+                    break;
+                case Lock:
+                    id = 1;
+                    if (args[1] != null) {
+                        id = (Integer)args[1];
+                    }
+                    lockMode = LockModeType.NONE;
+                    if (args[2] != null) {
+                        lockMode = (LockModeType)args[2];
+                    }
+                    employee = employees.get(id);
+                    log.trace("Employee=" + employee);
+                    Map<String, Object> lockProps = buildPropsMap(args, 3);
+                    if (lockProps != null) {
+                        em.lock(employee, lockMode, lockProps);
+                    } else {
+                        em.lock(employee, lockMode);
+                    }
+                    break;
+                case LockObject:
+                    em.lock(args[1], (LockModeType) args[2]);
+                    break;
+                case UpdateEmployee:
+                    id = 1;
+                    if (args.length > 1) {
+                        id = (Integer) args[1];
+                    }
+                    employee = employees.get(id);
+                    log.trace("Employee (before):" + employee);
+                    String newFirstName = "Unknown";
+                    if (args.length > 2) {
+                        newFirstName = (String) args[2];
+                    } else {
+                        newFirstName = (new Date()).toString();
+                    }
+                    employee.setFirstName(newFirstName);
+                    log.trace("Employee (after) :" + employee);
+                    break;
 
-                    case Detach:
-                        id = 1;
-                        if (args[1] != null) {
-                            id = (Integer)args[1];
-                        }
-                        employee = employees.get(id);
-                        log.trace("Employee (before) :" + employee);
-                        LockEmployee detEmployee = ((OpenJPAEntityManager) em
-                            .getDelegate()).detachCopy(employee);
-                        employees.put((Integer)args[2], detEmployee);
-                        log.trace("Employee (after)  :" + detEmployee);
-                        break;
+                case Detach:
+                    id = 1;
+                    if (args[1] != null) {
+                        id = (Integer)args[1];
+                    }
+                    employee = employees.get(id);
+                    log.trace("Employee (before) :" + employee);
+                    LockEmployee detEmployee = ((OpenJPAEntityManager) em
+                        .getDelegate()).detachCopy(employee);
+                    employees.put((Integer)args[2], detEmployee);
+                    log.trace("Employee (after)  :" + detEmployee);
+                    break;
 
-                    case StartTx:
-                        em.getTransaction().begin();
-                        break;
-                    case CommitTx:
-                        em.getTransaction().commit();
-                        break;
-                    case RollbackTx:
-                        em.getTransaction().rollback();
-                        break;
+                case StartTx:
+                    em.getTransaction().begin();
+                    break;
+                case CommitTx:
+                    em.getTransaction().commit();
+                    break;
+                case RollbackTx:
+                    em.getTransaction().rollback();
+                    break;
 
-                    case NewThread:
-                        int childToRun = (Integer) args[1];
-                        TestThread t1 = new TestThread(childToRun, actions);
-                        threads.add(t1);
-                        break;
-                    case StartThread:
-                        threads.get((Integer) args[1]).start();
-                        break;
-                    case Notify:
-                        int notifyThreadid = 0;
-                        if (args.length > 1 && args[1] != null) {
-                            notifyThreadid = (Integer) args[1];
-                        }
-                        if (args.length > 2) {
-                            Thread.sleep((Integer) args[2]);
-                        }
-                        if( notifyThreadid == 0) {
-                            notifyParent();
-                        } else {
-                            threads.get(notifyThreadid).notifyThread();
-                        }
-                        break;
-                    case Wait:
-                        int waitThreadid = threadToRun;
-                        if (args.length > 1 && args[1] != null) {
-                            waitThreadid = (Integer) args[1];
-                        }
-                        int waitTime = 5000; //15000;
-                        if (args.length > 2 && args[2] != null) {
-                            waitTime = (Integer) args[2];
-                        }
-                        if( waitThreadid != 0) {
-                            thisThread.wait(waitTime);
-                        } else {
-                            synchronized (this) {
-                                wait(waitTime);
-                            }
+                case NewThread:
+                    int childToRun = (Integer) args[1];
+                    TestThread t1 = new TestThread(childToRun, actions);
+                    threads.add(t1);
+                    break;
+                case StartThread:
+                    threads.get((Integer) args[1]).start();
+                    break;
+                case Notify:
+                    int notifyThreadid = 0;
+                    if (args.length > 1 && args[1] != null) {
+                        notifyThreadid = (Integer) args[1];
+                    }
+                    if (args.length > 2) {
+                        Thread.sleep((Integer) args[2]);
+                    }
+                    if( notifyThreadid == 0) {
+                        notifyParent();
+                    } else {
+                        threads.get(notifyThreadid).notifyThread();
+                    }
+                    break;
+                case Wait:
+                    int waitThreadid = threadToRun;
+                    if (args.length > 1 && args[1] != null) {
+                        waitThreadid = (Integer) args[1];
+                    }
+                    int waitTime = 5000; //15000;
+                    if (args.length > 2 && args[2] != null) {
+                        waitTime = (Integer) args[2];
+                    }
+                    if( waitThreadid != 0) {
+                        thisThread.wait(waitTime);
+                    } else {
+                        synchronized (this) {
+                            wait(waitTime);
                         }
-                        break;
+                    }
+                    break;
 
-                    case EmployeeNotNull:
-                        id = 1;
-                        if (args[1] != null) {
-                            id = (Integer)args[1];
-                        }
-                        employee = employees.get(id);
-                        assertNotNull(employee);
-                        break;
-                    case TestEmployee:
-                        id = 1;
-                        if (args[1] != null) {
-                            id = (Integer)args[1];
+                case EmployeeNotNull:
+                    id = 1;
+                    if (args[1] != null) {
+                        id = (Integer)args[1];
+                    }
+                    employee = employees.get(id);
+                    assertNotNull(employee);
+                    break;
+                case TestEmployee:
+                    id = 1;
+                    if (args[1] != null) {
+                        id = (Integer)args[1];
+                    }
+                    employee = employees.get(id);
+                    switch (args.length) {
+                    case 4:
+                        if (args[3] != null) {
+                            assertEquals("", saveVersion
+                                + (Integer) args[3], employee.getVersion());
                         }
-                        employee = employees.get(id);
-                        switch (args.length) {
-                        case 4:
-                            if (args[3] != null) {
-                                assertEquals("", saveVersion
-                                    + (Integer) args[3], employee.getVersion());
-                            }
-                        case 3:
-                            if (args[2] != null) {
-                                assertEquals("", (String) args[2], employee
-                                    .getFirstName());
-                            }
-                        case 2:
-                            if (args[1] != null) {
-                                assertEquals("", id.intValue(),
-                                    employee.getId());
-                            }
-                            break;
-                        case 1:
-                            assertNull(employee);
+                    case 3:
+                        if (args[2] != null) {
+                            assertEquals("", (String) args[2], employee
+                                .getFirstName());
                         }
-                        break;
-                    case SaveVersion:
-                        id = 1;
-                        if (args.length > 1) {
-                            id = (Integer) args[1];
-                        }
-                        employee = employees.get(id);
-                        saveVersion = employee.getVersion();
-                        log.trace("save version= " + saveVersion);
-                        break;
-                    case TestVersion:
-                        id = 1;
+                    case 2:
                         if (args[1] != null) {
-                            id = (Integer) args[1];
+                            assertEquals("", id.intValue(),
+                                employee.getId());
                         }
-                        int increment = (Integer)args[2];
-                        employee = employees.get(id);
-                        log.trace("test version: expected="
-                            + (saveVersion + increment) + ", testing="
-                            + employee.getVersion());
-
-                        assertEquals("", saveVersion + increment, employee
-                            .getVersion());
                         break;
-                    case TestLockMode:
-                        id = 1;
-                        if (args[1] != null) {
-                            id = (Integer) args[1];
-                        }
-                        employee = employees.get(id);
-                        LockModeType expectedlockMode = (LockModeType)args[2];
-                        LockModeType testinglockMode = em.getLockMode(employee);
-                        log.trace("test version: expected=" + expectedlockMode
-                            + ", testing=" + testinglockMode);
+                    case 1:
+                        assertNull(employee);
+                    }
+                    break;
+                case SaveVersion:
+                    id = 1;
+                    if (args.length > 1) {
+                        id = (Integer) args[1];
+                    }
+                    employee = employees.get(id);
+                    saveVersion = employee.getVersion();
+                    log.trace("save version= " + saveVersion);
+                    break;
+                case TestVersion:
+                    id = 1;
+                    if (args[1] != null) {
+                        id = (Integer) args[1];
+                    }
+                    int increment = (Integer)args[2];
+                    employee = employees.get(id);
+                    log.trace("test version: expected="
+                        + (saveVersion + increment) + ", testing="
+                        + employee.getVersion());
 
-                        assertEquals("", getCanonical(expectedlockMode),
-                            getCanonical(testinglockMode));
-                        break;
-                    case ResetException:
-                        thisThread.throwable = null;
-                        break;
-                    case TestException:
-                        List<Class<?>> expectedExceptions = null;
-                        if (args.length > 2) {
-                            expectedExceptions = new ArrayList<Class<?>>();
-                            for (int i = 2; i < args.length; ++i) {
-                                if (args[i] instanceof Object[]) {
-                                    for (Object o : (Object[]) args[i]) {
-                                        if (o != null && o instanceof Class) {
-                                            expectedExceptions
-                                                .add((Class<?>) o);
-                                        }
-                                    }
-                                } else {
-                                    if (args[i] != null
-                                        && args[i] instanceof Class) {
+                    assertEquals("", saveVersion + increment, employee
+                        .getVersion());
+                    break;
+                case TestLockMode:
+                    id = 1;
+                    if (args[1] != null) {
+                        id = (Integer) args[1];
+                    }
+                    employee = employees.get(id);
+                    LockModeType expectedlockMode = (LockModeType)args[2];
+                    LockModeType testinglockMode = em.getLockMode(employee);
+                    log.trace("test version: expected=" + expectedlockMode
+                        + ", testing=" + testinglockMode);
+
+                    assertEquals("", getCanonical(expectedlockMode),
+                        getCanonical(testinglockMode));
+                    break;
+                case ResetException:
+                    thisThread.throwable = null;
+                    break;
+                case TestException:
+                    List<Class<?>> expectedExceptions = null;
+                    if (args.length > 2) {
+                        expectedExceptions = new ArrayList<Class<?>>();
+                        for (int i = 2; i < args.length; ++i) {
+                            if (args[i] instanceof Object[]) {
+                                for (Object o : (Object[]) args[i]) {
+                                    if (o != null && o instanceof Class) {
                                         expectedExceptions
-                                            .add((Class<?>) args[i]);
+                                            .add((Class<?>) o);
                                     }
                                 }
-                            }
-                        }
-                        String testExClass = null;
-                        Throwable curThrowable = null;
-                        int threadId = threadToRun;
-                        if (args.length > 1) {
-                            threadId = (Integer) args[1];
-                        }
-                        TestThread exThread = threads.get(threadId);
-                        curThrowable = exThread.throwable;
-                        testExClass = processException(curAction, curThrowable);
-
-                        boolean exMatched = false;
-                        if (expectedExceptions != null
-                            && expectedExceptions.size() > 0) {
-                            for (Class<?> expectedException :
-                                expectedExceptions) {
-                                if (matchExpectedException(expectedException,
-                                    curThrowable)) {
-                                    exMatched = true;
-                                    break;
+                            } else {
+                                if (args[i] != null
+                                    && args[i] instanceof Class) {
+                                    expectedExceptions
+                                        .add((Class<?>) args[i]);
                                 }
                             }
-                        } else {
-                            if (curThrowable == null) {
+                        }
+                    }
+                    String testExClass = null;
+                    Throwable curThrowable = null;
+                    int threadId = threadToRun;
+                    if (args.length > 1) {
+                        threadId = (Integer) args[1];
+                    }
+                    TestThread exThread = threads.get(threadId);
+                    curThrowable = exThread.throwable;
+                    testExClass = processException(curAction, curThrowable);
+
+                    boolean exMatched = false;
+                    if (expectedExceptions != null
+                        && expectedExceptions.size() > 0) {
+                        for (Class<?> expectedException :
+                            expectedExceptions) {
+                            if (matchExpectedException(expectedException,
+                                curThrowable)) {
                                 exMatched = true;
+                                break;
                             }
                         }
-                        if (!exMatched) {
-                            log.trace(testExClass);
-                            if (curThrowable != null) {
-                                logStack(curThrowable);
-                            }
+                    } else {
+                        if (curThrowable == null) {
+                            exMatched = true;
                         }
-                        assertTrue("Expecting=" + expectedExceptions
-                            + ", Testing=" + testExClass, exMatched);
-                        exThread.throwable = null;
-                        break;
+                    }
+                    if (!exMatched) {
+                        log.trace(testExClass);
+                        if (curThrowable != null) {
+                            logStack(curThrowable);
+                        }
+                    }
+                    assertTrue("Expecting=" + expectedExceptions
+                        + ", Testing=" + testExClass, exMatched);
+                    exThread.throwable = null;
+                    break;
 
-                    case WaitAllChildren:
-                        // wait for threads to die or timeout
-                        log.trace("checking if thread is alive for " +
-                            (endTime-System.currentTimeMillis()) + "ms.");
-                        int deadThreads = 0;
-                        List<TestThread> proceedThread =
-                            new ArrayList<TestThread>(threads);
-                        while (proceedThread.size() > 0
-                            && System.currentTimeMillis() < endTime) {
-                            for (Thread thread : proceedThread) {
-                                if (thread.isAlive()) {
-                                    log.trace(thread + " is still alive, wait" +
-                                        " for 500ms and try again.");
-                                    try {
-                                        Thread.sleep(500);
-                                    } catch (InterruptedException e1) {
-                                    }
-                                    log.trace("waiting children thread ("
-                                        + (endTime - System.currentTimeMillis())
-                                            + " ms left)");
-                                    continue;
-                                } else {
-                                    deadThreads++;
-                                    proceedThread.remove(thread);
-                                    break;
+                case WaitAllChildren:
+                    // wait for threads to die or timeout
+                    log.trace("checking if thread is alive for " +
+                        (endTime-System.currentTimeMillis()) + "ms.");
+                    int deadThreads = 0;
+                    List<TestThread> proceedThread =
+                        new ArrayList<TestThread>(threads);
+                    while (proceedThread.size() > 0
+                        && System.currentTimeMillis() < endTime) {
+                        for (Thread thread : proceedThread) {
+                            if (thread.isAlive()) {
+                                log.trace(thread + " is still alive, wait" +
+                                    " for 500ms and try again.");
+                                try {
+                                    Thread.sleep(500);
+                                } catch (InterruptedException e1) {
                                 }
+                                log.trace("waiting children thread ("
+                                    + (endTime - System.currentTimeMillis())
+                                        + " ms left)");
+                                continue;
+                            } else {
+                                deadThreads++;
+                                proceedThread.remove(thread);
+                                break;
                             }
                         }
-                        if (proceedThread.size() > 0) {
+                    }
+                    if (proceedThread.size() > 0) {
                         log.trace(proceedThread.size()
                             + " threads still alive.");
                         for (TestThread thread : proceedThread) {
@@ -710,117 +709,110 @@
                             thread.interrupt();
                         }
                     }
-                        break;
-                    case JoinParent:
-                        for (Thread thread : threads) {
-                            boolean alive = thread.isAlive();
-                            if (alive) {
-                                log.trace(thread.getName() + " is still alive");
-                                try {
-                                    thread.interrupt();
-                                    thread.join();
-                                } catch (Exception e) {
-                                    logStack(e);
-                                }
+                    break;
+                case JoinParent:
+                    for (Thread thread : threads) {
+                        boolean alive = thread.isAlive();
+                        if (alive) {
+                            log.trace(thread.getName() + " is still alive");
+                            try {
+                                thread.interrupt();
+                                thread.join();
+                            } catch (Exception e) {
+                                logStack(e);
                             }
                         }
-                        break;
-                    case YieldThread:
-                        Thread.yield();
-                        break;
+                    }
+                    break;
+                case YieldThread:
+                    Thread.yield();
+                    break;
 
-                    case Sleep:
-                        Thread.sleep((Integer) args[1]);
-                        break;
-                    case DetachSerialize:
-                        id = 1;
-                        if (args[1] != null) {
-                            id = (Integer) args[1];
-                        }
-                        employee = employees.get(id);
-                        log.trace("Employee (before)=" + employee);
-                        ByteArrayOutputStream baos =
-                            new ByteArrayOutputStream();
-                        ObjectOutputStream oos = new ObjectOutputStream(baos);
-                        employee.writeExternal(oos);
-                        oos.flush(); baos.flush();
-                        ByteArrayInputStream bais = new ByteArrayInputStream(
-                            baos.toByteArray());
-                        ObjectInputStream ois = new ObjectInputStream(bais);
-                        LockEmployee transformedEmployee = new LockEmployee();
-                        transformedEmployee.readExternal(ois);
-                        log.trace("Employee (after) =" + transformedEmployee);
+                case Sleep:
+                    Thread.sleep((Integer) args[1]);
+                    break;
+                case DetachSerialize:
+                    id = 1;
+                    if (args[1] != null) {
+                        id = (Integer) args[1];
+                    }
+                    employee = employees.get(id);
+                    log.trace("Employee (before)=" + employee);
+                    ByteArrayOutputStream baos =
+                        new ByteArrayOutputStream();
+                    ObjectOutputStream oos = new ObjectOutputStream(baos);
+                    employee.writeExternal(oos);
+                    oos.flush(); baos.flush();
+                    ByteArrayInputStream bais = new ByteArrayInputStream(
+                        baos.toByteArray());
+                    ObjectInputStream ois = new ObjectInputStream(bais);
+                    LockEmployee transformedEmployee = new LockEmployee();
+                    transformedEmployee.readExternal(ois);
+                    log.trace("Employee (after) =" + transformedEmployee);
 
-                        employees.put((Integer)args[2],transformedEmployee);
-                        break;
-                    case Info:
-                        log.info(args[1]);
-                        break;
-                    case Warn:
-                        log.warn(args[1]);
-                        break;
-                    case Error:
-                        log.error(args[1]);
-                        break;
-                    case Trace:
-                        log.trace(args[1]);
-                        break;
+                    employees.put((Integer)args[2],transformedEmployee);
+                    break;
+                case Info:
+                    log.info(args[1]);
+                    break;
+                case Warn:
+                    log.warn(args[1]);
+                    break;
+                case Error:
+                    log.error(args[1]);
+                    break;
+                case Trace:
+                    log.trace(args[1]);
+                    break;
 
-                    case Test:
-                        em.lock("xxx", LockModeType.WRITE);
-                        break;
-                    default:
-                    }
-                } catch (Exception ex) {
-                    // only remember the first exception caught
-                    if (thisThread.throwable == null) {
-                        thisThread.throwable = ex;
-                    }
-                    log.trace("Caught exception and continue: " + ex);
-                    logStack(ex);
-                } catch (Error err) {
-                    // only remember the first exception caught
-                    if (thisThread.throwable == null) {
-                        thisThread.throwable = err;
-                    }
-                    log.trace("Caught exception and continue: " + err);
-                    logStack(err);
+                case Test:
+                    em.lock("xxx", LockModeType.WRITE);
+                    break;
+                default:
+                }
+            } catch (Exception ex) {
+                // only remember the first exception caught
+                if (thisThread.throwable == null) {
+                    thisThread.throwable = ex;
+                }
+                log.trace("Caught exception and continue: " + ex);
+                logStack(ex);
+            } catch (Error err) {
+                // only remember the first exception caught
+                if (thisThread.throwable == null) {
+                    thisThread.throwable = err;
                 }
+                log.trace("Caught exception and continue: " + err);
+                logStack(err);
             }
-            if (em != null && em.isOpen()) {
-                if (em.getTransaction().isActive()) {
-                    if (thisThread != null) {
-                        thisThread.systemRolledback = em.getTransaction()
-                            .getRollbackOnly();
-                    }
-                    try {
-                    if (em.getTransaction().getRollbackOnly()) {
-                        log.trace("finally: rolledback");
-                        em.getTransaction().rollback();
-                        log.trace("finally: rolledback completed");
-                    } else {
-                        log.trace("finally: commit");
-                        em.getTransaction().commit();
-                        log.trace("finally: commit completed");
-                    }
-                    } catch(Exception finalEx) {
-                        String failStr = processException(curAction, finalEx);
-                        log.trace("Fincally:" + failStr);
-                    }
+        }
+        if (em != null && em.isOpen()) {
+            if (em.getTransaction().isActive()) {
+                if (thisThread != null) {
+                    thisThread.systemRolledback = em.getTransaction()
+                        .getRollbackOnly();
                 }
-                em.close();
-                Throwable firstThrowable = thisThread.throwable;
-            if (firstThrowable != null) {
-                if( firstThrowable instanceof Error ) {
-                    throw (Error)firstThrowable;
+                try {
+                if (em.getTransaction().getRollbackOnly()) {
+                    log.trace("finally: rolledback");
+                    em.getTransaction().rollback();
+                    log.trace("finally: rolledback completed");
                 } else {
-                    ByteArrayOutputStream baos = new ByteArrayOutputStream();
-                    PrintStream ps = new PrintStream(baos);
-                    firstThrowable.printStackTrace(ps);
-                    ps.flush();
-                    fail(baos.toString());
+                    log.trace("finally: commit");
+                    em.getTransaction().commit();
+                    log.trace("finally: commit completed");
+                }
+                } catch(Exception finalEx) {
+                    String failStr = processException(curAction, finalEx);
+                    log.trace("Fincally:" + failStr);
                 }
             }
+            em.close();
+            Throwable firstThrowable = thisThread.throwable;
+            if (firstThrowable != null) {
+                if( firstThrowable instanceof Error )
+                    throw (Error)firstThrowable;
+            }
             log.trace("<<<< Sequenced Test: Threads=" + threadToRun + '/'
                 + numThreads);
         }

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/lockmgr/TestFetchHints.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/lockmgr/TestFetchHints.java?rev=762409&r1=762408&r2=762409&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/lockmgr/TestFetchHints.java (original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/lockmgr/TestFetchHints.java Mon Apr  6 16:30:24 2009
@@ -1764,26 +1764,25 @@
             MixedLockLevels.LOCK_NONE);
 
         readLockLevelHintTest(fPlan, fConfig, hintName, String
-            .valueOf(MixedLockLevels.LOCK_READ), LockModeType.OPTIMISTIC,
+            .valueOf(MixedLockLevels.LOCK_READ), LockModeType.READ,
             MixedLockLevels.LOCK_READ);
         readLockLevelHintTest(fPlan, fConfig, hintName,
-            MixedLockLevels.LOCK_READ, LockModeType.OPTIMISTIC,
+            MixedLockLevels.LOCK_READ, LockModeType.READ,
             MixedLockLevels.LOCK_READ);
 
         readLockLevelHintTest(fPlan, fConfig, hintName, String
-            .valueOf(MixedLockLevels.LOCK_WRITE),
-            LockModeType.OPTIMISTIC_FORCE_INCREMENT,
+            .valueOf(MixedLockLevels.LOCK_WRITE), LockModeType.WRITE,
             MixedLockLevels.LOCK_WRITE);
         readLockLevelHintTest(fPlan, fConfig, hintName,
-            MixedLockLevels.LOCK_WRITE,
-            LockModeType.OPTIMISTIC_FORCE_INCREMENT,
+            MixedLockLevels.LOCK_WRITE, LockModeType.WRITE,
             MixedLockLevels.LOCK_WRITE);
 
         readLockLevelHintTest(fPlan, fConfig, hintName, String
             .valueOf(MixedLockLevels.LOCK_OPTIMISTIC), LockModeType.OPTIMISTIC,
             MixedLockLevels.LOCK_OPTIMISTIC);
-        readLockLevelHintTest(fPlan, fConfig, hintName, 10,
-            LockModeType.OPTIMISTIC, MixedLockLevels.LOCK_OPTIMISTIC);
+        readLockLevelHintTest(fPlan, fConfig, hintName,
+            MixedLockLevels.LOCK_OPTIMISTIC, LockModeType.OPTIMISTIC,
+            MixedLockLevels.LOCK_OPTIMISTIC);
 
         readLockLevelHintTest(fPlan, fConfig, hintName, String
             .valueOf(MixedLockLevels.LOCK_OPTIMISTIC_FORCE_INCREMENT),
@@ -1887,19 +1886,17 @@
             MixedLockLevels.LOCK_NONE);
 
         writeLockLevelHintTest(fPlan, fConfig, hintName, String
-            .valueOf(MixedLockLevels.LOCK_READ), LockModeType.OPTIMISTIC,
+            .valueOf(MixedLockLevels.LOCK_READ), LockModeType.READ,
             MixedLockLevels.LOCK_READ);
         writeLockLevelHintTest(fPlan, fConfig, hintName,
-            MixedLockLevels.LOCK_READ, LockModeType.OPTIMISTIC,
+            MixedLockLevels.LOCK_READ, LockModeType.READ,
             MixedLockLevels.LOCK_READ);
 
         writeLockLevelHintTest(fPlan, fConfig, hintName, String
-            .valueOf(MixedLockLevels.LOCK_WRITE),
-            LockModeType.OPTIMISTIC_FORCE_INCREMENT,
+            .valueOf(MixedLockLevels.LOCK_WRITE), LockModeType.WRITE,
             MixedLockLevels.LOCK_WRITE);
         writeLockLevelHintTest(fPlan, fConfig, hintName,
-            MixedLockLevels.LOCK_WRITE,
-            LockModeType.OPTIMISTIC_FORCE_INCREMENT,
+            MixedLockLevels.LOCK_WRITE, LockModeType.WRITE,
             MixedLockLevels.LOCK_WRITE);
 
         writeLockLevelHintTest(fPlan, fConfig, hintName, String
@@ -2022,22 +2019,19 @@
             MixedLockLevels.LOCK_NONE);
 
         readLockModeHintTest(fPlan, fConfig, hintName, "read",
-            LockModeType.OPTIMISTIC, MixedLockLevels.LOCK_OPTIMISTIC);
+            LockModeType.READ, MixedLockLevels.LOCK_READ);
         readLockModeHintTest(fPlan, fConfig, hintName, LockModeType.READ,
-            LockModeType.OPTIMISTIC, MixedLockLevels.LOCK_OPTIMISTIC);
+            LockModeType.READ, MixedLockLevels.LOCK_READ);
         readLockModeHintTest(fPlan, fConfig, hintName,
-            LockModeType.READ.name(), LockModeType.OPTIMISTIC,
-            MixedLockLevels.LOCK_OPTIMISTIC);
+            LockModeType.READ.name(), LockModeType.READ,
+            MixedLockLevels.LOCK_READ);
 
         readLockModeHintTest(fPlan, fConfig, hintName, "write",
-            LockModeType.OPTIMISTIC_FORCE_INCREMENT,
-            MixedLockLevels.LOCK_OPTIMISTIC_FORCE_INCREMENT);
+            LockModeType.WRITE, MixedLockLevels.LOCK_WRITE);
         readLockModeHintTest(fPlan, fConfig, hintName, LockModeType.WRITE,
-            LockModeType.OPTIMISTIC_FORCE_INCREMENT,
-            MixedLockLevels.LOCK_OPTIMISTIC_FORCE_INCREMENT);
+            LockModeType.WRITE, MixedLockLevels.LOCK_WRITE);
         readLockModeHintTest(fPlan, fConfig, hintName, LockModeType.WRITE
-            .name(), LockModeType.OPTIMISTIC_FORCE_INCREMENT,
-            MixedLockLevels.LOCK_OPTIMISTIC_FORCE_INCREMENT);
+            .name(), LockModeType.WRITE, MixedLockLevels.LOCK_WRITE);
 
         readLockModeHintTest(fPlan, fConfig, hintName, "optimistic",
             LockModeType.OPTIMISTIC, MixedLockLevels.LOCK_OPTIMISTIC);
@@ -2164,21 +2158,18 @@
             .name(), LockModeType.NONE, MixedLockLevels.LOCK_NONE);
 
         writeLockModeHintTest(fPlan, fConfig, hintName, "read",
-            LockModeType.OPTIMISTIC, MixedLockLevels.LOCK_READ);
+            LockModeType.READ, MixedLockLevels.LOCK_READ);
         writeLockModeHintTest(fPlan, fConfig, hintName, LockModeType.READ,
-            LockModeType.OPTIMISTIC, MixedLockLevels.LOCK_READ);
+            LockModeType.READ, MixedLockLevels.LOCK_READ);
         writeLockModeHintTest(fPlan, fConfig, hintName, LockModeType.READ
-            .name(), LockModeType.OPTIMISTIC, MixedLockLevels.LOCK_READ);
+            .name(), LockModeType.READ, MixedLockLevels.LOCK_READ);
 
         writeLockModeHintTest(fPlan, fConfig, hintName, "write",
-            LockModeType.OPTIMISTIC_FORCE_INCREMENT,
-            MixedLockLevels.LOCK_WRITE);
+            LockModeType.WRITE, MixedLockLevels.LOCK_WRITE);
         writeLockModeHintTest(fPlan, fConfig, hintName, LockModeType.WRITE,
-            LockModeType.OPTIMISTIC_FORCE_INCREMENT,
-            MixedLockLevels.LOCK_WRITE);
+            LockModeType.WRITE, MixedLockLevels.LOCK_WRITE);
         writeLockModeHintTest(fPlan, fConfig, hintName, LockModeType.WRITE
-            .name(), LockModeType.OPTIMISTIC_FORCE_INCREMENT,
-            MixedLockLevels.LOCK_WRITE);
+            .name(), LockModeType.WRITE, MixedLockLevels.LOCK_WRITE);
 
         writeLockModeHintTest(fPlan, fConfig, hintName,
             "optimistic", LockModeType.OPTIMISTIC,

Modified: openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/FetchPlanHintHandler.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/FetchPlanHintHandler.java?rev=762409&r1=762408&r2=762409&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/FetchPlanHintHandler.java (original)
+++ openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/FetchPlanHintHandler.java Mon Apr  6 16:30:24 2009
@@ -201,7 +201,9 @@
             intValue = (Integer) value;
         if (intValue == null
             || (intValue != MixedLockLevels.LOCK_NONE
+                && intValue != MixedLockLevels.LOCK_READ
                 && intValue != MixedLockLevels.LOCK_OPTIMISTIC
+                && intValue != MixedLockLevels.LOCK_WRITE
                 && intValue != MixedLockLevels.LOCK_OPTIMISTIC_FORCE_INCREMENT
                 && intValue != MixedLockLevels.LOCK_PESSIMISTIC_READ
                 && intValue != MixedLockLevels.LOCK_PESSIMISTIC_WRITE

Modified: openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/MixedLockLevelsHelper.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/MixedLockLevelsHelper.java?rev=762409&r1=762408&r2=762409&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/MixedLockLevelsHelper.java (original)
+++ openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/MixedLockLevelsHelper.java Mon Apr  6 16:30:24 2009
@@ -36,10 +36,13 @@
     public static int toLockLevel(LockModeType mode) {
         if (mode == null || mode == LockModeType.NONE)
             return MixedLockLevels.LOCK_NONE;
-        if (mode == LockModeType.READ || mode == LockModeType.OPTIMISTIC)
+        if (mode == LockModeType.READ)
+            return MixedLockLevels.LOCK_READ;
+        if (mode == LockModeType.OPTIMISTIC)
             return MixedLockLevels.LOCK_OPTIMISTIC;
-        if (mode == LockModeType.WRITE
-            || mode == LockModeType.OPTIMISTIC_FORCE_INCREMENT)
+        if (mode == LockModeType.WRITE)
+            return MixedLockLevels.LOCK_WRITE;
+        if (mode == LockModeType.OPTIMISTIC_FORCE_INCREMENT)
             return MixedLockLevels.LOCK_OPTIMISTIC_FORCE_INCREMENT;
         if (mode == LockModeType.PESSIMISTIC_READ)
             return MixedLockLevels.LOCK_PESSIMISTIC_READ;
@@ -52,10 +55,14 @@
      * Translates internal lock level to javax.persistence LockModeType.
      */
     public static LockModeType fromLockLevel(int level) {
-        if (level < MixedLockLevels.LOCK_OPTIMISTIC)
+        if (level < MixedLockLevels.LOCK_READ)
             return LockModeType.NONE;
-        if (level < MixedLockLevels.LOCK_OPTIMISTIC_FORCE_INCREMENT)
+        if (level < MixedLockLevels.LOCK_OPTIMISTIC)
+            return LockModeType.READ;
+        if (level < MixedLockLevels.LOCK_WRITE)
             return LockModeType.OPTIMISTIC;
+        if (level < MixedLockLevels.LOCK_OPTIMISTIC_FORCE_INCREMENT)
+            return LockModeType.WRITE;
         if (level < MixedLockLevels.LOCK_PESSIMISTIC_READ)
             return LockModeType.OPTIMISTIC_FORCE_INCREMENT;
         if (level < MixedLockLevels.LOCK_PESSIMISTIC_WRITE)

Modified: openjpa/trunk/openjpa-persistence/src/main/resources/org/apache/openjpa/persistence/localizer.properties
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence/src/main/resources/org/apache/openjpa/persistence/localizer.properties?rev=762409&r1=762408&r2=762409&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence/src/main/resources/org/apache/openjpa/persistence/localizer.properties (original)
+++ openjpa/trunk/openjpa-persistence/src/main/resources/org/apache/openjpa/persistence/localizer.properties Mon Apr  6 16:30:24 2009
@@ -170,6 +170,7 @@
 invalid_entity_argument: Object being locked must be an valid and not detached \
     entity.
 bad-lock-level: Invalid lock mode/level. Valid values are \
-    "none"(0), "optimistic"(10), "optimistic-force-increment"(20), \
+    "none"(0), "read"(10), "optimistic"(15), "write"(20), \
+    "optimistic-force-increment"(25), \
     "pessimistic-read"(30), "pessimistic-write"(40) or \
     "pessimistic-force-increment"(50). Specified value: {0}.



Mime
View raw message