Author: allee8285
Date: Thu Mar 19 16:03:15 2009
New Revision: 756066

URL: http://svn.apache.org/viewvc?rev=756066&view=rev
Log:
OPENJPA-988 - Refactoring JPA2/MixedLockManager from persistence module to jdbc 
module. No functional changes.

Added:
    
openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/MixedLockManager.java
   (with props)
    
openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/MixedLockLevels.java
   (with props)
    
openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/MixedLockLevelsHelper.java
   (with props)
Removed:
    
openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/JPA2LockLevels.java
    
openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/JPA2LockManager.java
Modified:
    
openjpa/trunk/openjpa-jdbc/src/main/resources/org/apache/openjpa/jdbc/kernel/localizer.properties
    openjpa/trunk/openjpa-persistence/pom.xml
    
openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/EntityManagerImpl.java
    
openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/FetchPlanImpl.java
    
openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceExceptions.java
    
openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceProductDerivation.java
    
openjpa/trunk/openjpa-persistence/src/main/resources/org/apache/openjpa/persistence/localizer.properties
    openjpa/trunk/openjpa-project/src/doc/manual/ref_guide_runtime.xml

Added: 
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=756066&view=auto
==============================================================================
--- 
openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/MixedLockManager.java
 (added)
+++ 
openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/MixedLockManager.java
 Thu Mar 19 16:03:15 2009
@@ -0,0 +1,98 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.openjpa.jdbc.kernel;
+
+import java.sql.SQLException;
+
+import org.apache.openjpa.jdbc.meta.ClassMapping;
+import org.apache.openjpa.jdbc.sql.SQLExceptions;
+import org.apache.openjpa.jdbc.sql.Select;
+import org.apache.openjpa.kernel.MixedLockLevels;
+import org.apache.openjpa.kernel.OpenJPAStateManager;
+import org.apache.openjpa.lib.util.Localizer;
+import org.apache.openjpa.util.OptimisticException;
+
+/**
+ * Mixed lock manager implements both optimistic and pessimistic locking
+ * semantics in parallel to the JPA 2.0 specification.
+ *
+ * @author Albert Lee
+ * @since 2.0.0
+ */
+public class MixedLockManager extends PessimisticLockManager {
+
+    private static final Localizer _loc = Localizer
+        .forPackage(MixedLockManager.class);
+
+    /*
+     * (non-Javadoc)
+     * @see org.apache.openjpa.jdbc.kernel.PessimisticLockManager
+     *  #selectForUpdate(org.apache.openjpa.jdbc.sql.Select,int)
+     */
+    public boolean selectForUpdate(Select sel, int lockLevel) {
+        return (lockLevel >= MixedLockLevels.LOCK_PESSIMISTIC_READ) 
+            ? super.selectForUpdate(sel, lockLevel) : false;
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see org.apache.openjpa.jdbc.kernel.PessimisticLockManager#
+     *  lockInternal(org.apache.openjpa.kernel.OpenJPAStateManager, int, int,
+     *               java.lang.Object)
+     */
+    protected void lockInternal(OpenJPAStateManager sm, int level, int timeout,
+        Object sdata, boolean postLockVersionCheck) {
+        if (level >= MixedLockLevels.LOCK_PESSIMISTIC_FORCE_INCREMENT) {
+            setVersionCheckOnReadLock(true);
+            setVersionUpdateOnWriteLock(true);
+            super.lockInternal(sm, level, timeout, sdata, 
postLockVersionCheck);
+        } else if (level >= MixedLockLevels.LOCK_PESSIMISTIC_READ) {
+            setVersionCheckOnReadLock(true);
+            setVersionUpdateOnWriteLock(false);
+            super.lockInternal(sm, level, timeout, sdata, 
postLockVersionCheck);
+        } else if (level >= MixedLockLevels.LOCK_OPTIMISTIC) {
+            setVersionCheckOnReadLock(true);
+            setVersionUpdateOnWriteLock(true);
+            optimisticLockInternal(sm, level, timeout, sdata,
+                postLockVersionCheck);
+        }
+    }
+
+    protected void optimisticLockInternal(OpenJPAStateManager sm, int level,
+        int timeout, Object sdata, boolean postLockVersionCheck) {
+        super.optimisticLockInternal(sm, level, timeout, sdata,
+            postLockVersionCheck);
+        if (postLockVersionCheck) {
+            if (level >= MixedLockLevels.LOCK_PESSIMISTIC_READ) {
+                ClassMapping mapping = (ClassMapping) sm.getMetaData();
+                try {
+                    if (!mapping.getVersion().checkVersion(sm, this.getStore(),
+                        true)) {
+                        throw (new OptimisticException(_loc.get(
+                            "optimistic-violation-lock").getMessage()))
+                            .setFailedObject(sm.getObjectId());
+                    }
+                } catch (SQLException se) {
+                    throw SQLExceptions.getStore(se, sm.getObjectId(),
+                        getStore().getDBDictionary());
+                }
+            }
+        }
+    }
+}

Propchange: 
openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/MixedLockManager.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: 
openjpa/trunk/openjpa-jdbc/src/main/resources/org/apache/openjpa/jdbc/kernel/localizer.properties
URL: 
http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/resources/org/apache/openjpa/jdbc/kernel/localizer.properties?rev=756066&r1=756065&r2=756066&view=diff
==============================================================================
--- 
openjpa/trunk/openjpa-jdbc/src/main/resources/org/apache/openjpa/jdbc/kernel/localizer.properties
 (original)
+++ 
openjpa/trunk/openjpa-jdbc/src/main/resources/org/apache/openjpa/jdbc/kernel/localizer.properties
 Thu Mar 19 16:03:15 2009
@@ -139,4 +139,6 @@
 finder-cached: Cached finder for "{0}" SQL: "{1}"
 finder-not-cachable: Finder for "{0}" is not cachable.
 finder-add-pattern: Exclusion pattern "{0}" for finder query has invalidated \
-       {1} existing entries "{2}"
\ No newline at end of file
+       {1} existing entries "{2}"
+optimistic-violation-lock: An optimistic lock violation was detected when \
+    locking object instance.
\ No newline at end of file

Added: 
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=756066&view=auto
==============================================================================
--- 
openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/MixedLockLevels.java
 (added)
+++ 
openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/MixedLockLevels.java
 Thu Mar 19 16:03:15 2009
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.openjpa.kernel;
+
+/**
+ * Defines lock levels used for MixedLockManager.
+ *
+ * @author Albert Lee
+ * @since 2.0.0
+ */
+public interface MixedLockLevels extends LockLevels {
+
+    /**
+     * Generic optimistic read lock level. Value of 10.
+     *
+     */
+    public static final int LOCK_OPTIMISTIC = LOCK_READ;
+
+    /**
+     * Generic optimistic write lock level. Value of 20.
+     */
+    public static final int LOCK_OPTIMISTIC_FORCE_INCREMENT =
+        LockLevels.LOCK_WRITE;
+
+    /**
+     * Generic pessimistic read lock level. Value of 30.
+     */
+    public static final int LOCK_PESSIMISTIC_READ = 30;
+
+    /**
+     * Generic pessimistic write lock level. Value of 40.
+     */
+    public static final int LOCK_PESSIMISTIC_WRITE = 40;
+
+    /**
+     * Generic pessimistic force increment level. Value of 50.
+     */
+    public static final int LOCK_PESSIMISTIC_FORCE_INCREMENT = 50;
+
+}

Propchange: 
openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/MixedLockLevels.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: openjpa/trunk/openjpa-persistence/pom.xml
URL: 
http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence/pom.xml?rev=756066&r1=756065&r2=756066&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence/pom.xml (original)
+++ openjpa/trunk/openjpa-persistence/pom.xml Thu Mar 19 16:03:15 2009
@@ -40,11 +40,6 @@
             <version>${pom.version}</version>
         </dependency>
         <dependency>
-            <groupId>org.apache.openjpa</groupId>
-            <artifactId>openjpa-jdbc</artifactId>
-            <version>${pom.version}</version>
-        </dependency>
-        <dependency>
             <groupId>org.apache.geronimo.specs</groupId>
             <artifactId>geronimo-jpa_2.0_spec</artifactId>
         </dependency>

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=756066&r1=756065&r2=756066&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
 Thu Mar 19 16:03:15 2009
@@ -48,13 +48,12 @@
 import org.apache.openjpa.ee.ManagedRuntime;
 import org.apache.openjpa.enhance.PCEnhancer;
 import org.apache.openjpa.enhance.PCRegistry;
-import org.apache.openjpa.jdbc.kernel.JDBCFetchConfiguration;
 import org.apache.openjpa.kernel.AbstractBrokerFactory;
 import org.apache.openjpa.kernel.Broker;
 import org.apache.openjpa.kernel.DelegatingBroker;
 import org.apache.openjpa.kernel.FetchConfiguration;
 import org.apache.openjpa.kernel.FindCallbacks;
-import org.apache.openjpa.kernel.LockLevels;
+import org.apache.openjpa.kernel.MixedLockLevels;
 import org.apache.openjpa.kernel.OpCallbacks;
 import org.apache.openjpa.kernel.OpenJPAStateManager;
 import org.apache.openjpa.kernel.PreparedQuery;
@@ -1075,13 +1074,14 @@
 
     public LockModeType getLockMode(Object entity) {
         assertNotCloseInvoked();
-        return JPA2LockLevels.fromLockLevel(_broker.getLockLevel(entity));
+        return MixedLockLevelsHelper.fromLockLevel(
+            _broker.getLockLevel(entity));
     }
 
     public void lock(Object entity, LockModeType mode) {
         assertNotCloseInvoked();
         assertValidAttchedEntity(entity);
-        _broker.lock(entity, JPA2LockLevels.toLockLevel(mode), -1, this);
+        _broker.lock(entity, MixedLockLevelsHelper.toLockLevel(mode), -1, 
this);
     }
 
     public void lock(Object entity) {
@@ -1093,7 +1093,8 @@
     public void lock(Object entity, LockModeType mode, int timeout) {
         assertNotCloseInvoked();
         assertValidAttchedEntity(entity);
-        _broker.lock(entity, JPA2LockLevels.toLockLevel(mode), timeout, this);
+        _broker.lock(entity, MixedLockLevelsHelper.toLockLevel(mode), timeout,
+             this);
     }
 
     public void lock(Object entity, LockModeType mode,
@@ -1104,8 +1105,8 @@
 
         boolean fcPushed = pushLockProperties(mode, properties);
         try {
-            _broker.lock(entity, JPA2LockLevels.toLockLevel(mode), _broker
-                .getFetchConfiguration().getLockTimeout(), this);
+            _broker.lock(entity, MixedLockLevelsHelper.toLockLevel(mode),
+                _broker.getFetchConfiguration().getLockTimeout(), this);
         } finally {
             popLockProperties(fcPushed);
         }
@@ -1118,7 +1119,8 @@
 
     public void lockAll(Collection entities, LockModeType mode, int timeout) {
         assertNotCloseInvoked();
-        _broker.lockAll(entities, JPA2LockLevels.toLockLevel(mode), timeout, 
this);
+        _broker.lockAll(entities, MixedLockLevelsHelper.toLockLevel(mode),
+            timeout, this);
     }
 
     public void lockAll(Object... entities) {
@@ -1571,7 +1573,7 @@
                                 fCfg.setLockTimeout(value);
                                 break;
                             case ReadLockLevel:
-                                if (value != LockLevels.LOCK_NONE
+                                if (value != MixedLockLevels.LOCK_NONE
                                     && value != fCfg.getReadLockLevel()) {
                                     if (!fcPushed) {
                                         fCfg = 
_broker.pushFetchConfiguration();
@@ -1581,7 +1583,7 @@
                                 }
                                 break;
                             case WriteLockLevel:
-                                if (value != LockLevels.LOCK_NONE
+                                if (value != MixedLockLevels.LOCK_NONE
                                     && value != fCfg.getWriteLockLevel()) {
                                     if (!fcPushed) {
                                         fCfg = 
_broker.pushFetchConfiguration();
@@ -1613,8 +1615,8 @@
                 FetchConfigProperty.WriteLockLevel }, properties);
         }
         // override with the specific lockMode, if needed.
-        int setReadLevel = JPA2LockLevels.toLockLevel(mode);
-        if (setReadLevel != JPA2LockLevels.LOCK_NONE) {
+        int setReadLevel = MixedLockLevelsHelper.toLockLevel(mode);
+        if (setReadLevel != MixedLockLevels.LOCK_NONE) {
             // Set overriden read lock level
             FetchConfiguration fCfg = _broker.getFetchConfiguration();
             int curReadLevel = fCfg.getReadLockLevel();
@@ -1627,13 +1629,13 @@
             }
             // Set overriden isolation level for pessimistic-read/write
             switch (setReadLevel) {
-            case JPA2LockLevels.LOCK_PESSIMISTIC_READ:
+            case MixedLockLevels.LOCK_PESSIMISTIC_READ:
                 fcPushed = setIsolationForPessimisticLock(fCfg, fcPushed,
                     Connection.TRANSACTION_REPEATABLE_READ);
                 break;
 
-            case JPA2LockLevels.LOCK_PESSIMISTIC_WRITE:
-            case JPA2LockLevels.LOCK_PESSIMISTIC_FORCE_INCREMENT:
+            case MixedLockLevels.LOCK_PESSIMISTIC_WRITE:
+            case MixedLockLevels.LOCK_PESSIMISTIC_FORCE_INCREMENT:
                 fcPushed = setIsolationForPessimisticLock(fCfg, fcPushed,
                     Connection.TRANSACTION_SERIALIZABLE);
                 break;
@@ -1650,7 +1652,8 @@
             fCfg = _broker.pushFetchConfiguration();
             fcPushed = true;
         }
-        ((JDBCFetchConfiguration) fCfg).setIsolation(level);
+        // TODO: refactoring under OPENJPA-957
+//        ((JDBCFetchConfiguration) fCfg).setIsolation(level);
         return fcPushed;
     }
 

Modified: 
openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/FetchPlanImpl.java
URL: 
http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/FetchPlanImpl.java?rev=756066&r1=756065&r2=756066&view=diff
==============================================================================
--- 
openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/FetchPlanImpl.java
 (original)
+++ 
openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/FetchPlanImpl.java
 Thu Mar 19 16:03:15 2009
@@ -23,12 +23,12 @@
 import java.util.Collection;
 import java.util.Iterator;
 import java.util.Map;
-import java.util.Set;
 
 import javax.persistence.LockModeType;
 
 import org.apache.openjpa.kernel.DelegatingFetchConfiguration;
 import org.apache.openjpa.kernel.FetchConfiguration;
+import org.apache.openjpa.kernel.MixedLockLevels;
 
 /**
  * Implements FetchPlan via delegation to FetchConfiguration.
@@ -245,20 +245,20 @@
     }
 
     public LockModeType getReadLockMode() {
-        return JPA2LockLevels.fromLockLevel(_fetch.getReadLockLevel());
+        return MixedLockLevelsHelper.fromLockLevel(_fetch.getReadLockLevel());
     }
 
     public FetchPlan setReadLockMode(LockModeType mode) {
-        _fetch.setReadLockLevel(JPA2LockLevels.toLockLevel(mode));
+        _fetch.setReadLockLevel(MixedLockLevelsHelper.toLockLevel(mode));
         return this;
     }
 
     public LockModeType getWriteLockMode() {
-        return JPA2LockLevels.fromLockLevel(_fetch.getWriteLockLevel());
+        return MixedLockLevelsHelper.fromLockLevel(_fetch.getWriteLockLevel());
     }
 
     public FetchPlan setWriteLockMode(LockModeType mode) {
-        _fetch.setWriteLockLevel(JPA2LockLevels.toLockLevel(mode));
+        _fetch.setWriteLockLevel(MixedLockLevelsHelper.toLockLevel(mode));
         return this;
     }
     

Added: 
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=756066&view=auto
==============================================================================
--- 
openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/MixedLockLevelsHelper.java
 (added)
+++ 
openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/MixedLockLevelsHelper.java
 Thu Mar 19 16:03:15 2009
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.openjpa.persistence;
+
+import javax.persistence.LockModeType;
+
+import org.apache.openjpa.kernel.MixedLockLevels;
+
+/**
+ * Helper methods translate between JPA-defined lock mode and OpenJPA 
+ * internal lock levels.
+ *
+ * @author Albert Lee
+ * @since 2.0.0
+ */
+public class MixedLockLevelsHelper {
+    /**
+     * Translates javax.persistence LockModeType to internal lock level.
+     */
+    public static int toLockLevel(LockModeType mode) {
+        if (mode == null || mode == LockModeType.NONE)
+            return MixedLockLevels.LOCK_NONE;
+        if (mode == LockModeType.READ || mode == LockModeType.OPTIMISTIC)
+            return MixedLockLevels.LOCK_READ;
+        if (mode == LockModeType.WRITE
+            || mode == LockModeType.OPTIMISTIC_FORCE_INCREMENT)
+            return MixedLockLevels.LOCK_WRITE;
+        // TODO: if (mode == LockModeType.PESSIMISTIC_READ)
+        // TODO: return LockLevels.LOCK_PESSIMISTIC_READ;
+        if (mode == LockModeType.PESSIMISTIC)
+            return MixedLockLevels.LOCK_PESSIMISTIC_WRITE;
+        return MixedLockLevels.LOCK_PESSIMISTIC_FORCE_INCREMENT;
+    }
+
+    /**
+     * Translates internal lock level to javax.persistence LockModeType.
+     */
+    public static LockModeType fromLockLevel(int level) {
+        if (level < MixedLockLevels.LOCK_OPTIMISTIC)
+            return null;
+        if (level < MixedLockLevels.LOCK_OPTIMISTIC_FORCE_INCREMENT)
+            return LockModeType.READ;
+        if (level < MixedLockLevels.LOCK_PESSIMISTIC_READ)
+            return LockModeType.WRITE;
+        if (level < MixedLockLevels.LOCK_PESSIMISTIC_WRITE)
+            return LockModeType.PESSIMISTIC;
+        // TODO: return LockModeType.PESSIMISTIC_READ;
+        if (level < MixedLockLevels.LOCK_PESSIMISTIC_FORCE_INCREMENT)
+            return LockModeType.PESSIMISTIC;
+        // TODO: return LockModeType.PESSIMISTIC_WRITE;
+        return LockModeType.PESSIMISTIC_FORCE_INCREMENT;
+    }
+}

Propchange: 
openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/MixedLockLevelsHelper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: 
openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceExceptions.java
URL: 
http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceExceptions.java?rev=756066&r1=756065&r2=756066&view=diff
==============================================================================
--- 
openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceExceptions.java
 (original)
+++ 
openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceExceptions.java
 Thu Mar 19 16:03:15 2009
@@ -14,13 +14,14 @@
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
- * under the License.    
+ * under the License.
  */
 package org.apache.openjpa.persistence;
 
 import java.lang.reflect.InvocationTargetException;
 
 import org.apache.openjpa.kernel.Broker;
+import org.apache.openjpa.kernel.MixedLockLevels;
 import org.apache.openjpa.util.Exceptions;
 import org.apache.openjpa.util.LockException;
 import org.apache.openjpa.util.NoTransactionException;
@@ -147,25 +148,25 @@
      */
     private static Throwable translateStoreException(OpenJPAException ke) {
         Exception e;
-        Throwable cause = (ke.getNestedThrowables() != null 
+        Throwable cause = (ke.getNestedThrowables() != null
                         && ke.getNestedThrowables().length == 1)
                          ? ke.getNestedThrowables()[0] : null;
-        if (ke.getSubtype() == StoreException.OBJECT_NOT_FOUND 
+        if (ke.getSubtype() == StoreException.OBJECT_NOT_FOUND
          || cause instanceof ObjectNotFoundException) {
                 e = new org.apache.openjpa.persistence.EntityNotFoundException
                     (ke.getMessage(), getNestedThrowables(ke),
                         getFailedObject(ke), ke.isFatal());
-        } else if (ke.getSubtype() == StoreException.OPTIMISTIC 
+        } else if (ke.getSubtype() == StoreException.OPTIMISTIC
                        || cause instanceof OptimisticException) {
                e = new org.apache.openjpa.persistence.OptimisticLockException
                     (ke.getMessage(), getNestedThrowables(ke),
                         getFailedObject(ke), ke.isFatal());
-        } else if (ke.getSubtype() == StoreException.LOCK 
+        } else if (ke.getSubtype() == StoreException.LOCK
                 || cause instanceof LockException) {
             LockException lockEx = (LockException)
                 (ke instanceof LockException ? ke : cause);
-            if (lockEx != null && lockEx.getLockLevel() >= 
-                JPA2LockLevels.LOCK_PESSIMISTIC_READ) {
+            if (lockEx != null && lockEx.getLockLevel() >=
+                MixedLockLevels.LOCK_PESSIMISTIC_READ) {
                 if (!lockEx.isFatal()) {
                     e = new org.apache.openjpa.persistence
                         .LockTimeoutException(
@@ -211,10 +212,10 @@
 
     /**
      * Translate the given user exception.
-     * If a {link {...@link OpenJPAException#getSubtype() sub type} is set on 
the 
+     * If a {link {...@link OpenJPAException#getSubtype() sub type} is set on 
the
      * given exception then a corresponding facade-level exception i.e. the
      * exceptions that inherit JPA-defined exceptions is generated.
-     * If given exception is not further classified to a sub type, then 
+     * If given exception is not further classified to a sub type, then
      * an [...@link {...@link #translateInternalException(OpenJPAException)} 
attempt}
      * is made to translate the given OpenJPAException by its internal cause.
      */
@@ -222,7 +223,7 @@
         Exception e;
         switch (ke.getSubtype()) {
             case UserException.NO_TRANSACTION:
-                e = new 
+                e = new
                     org.apache.openjpa.persistence.TransactionRequiredException
                         (ke.getMessage(), getNestedThrowables(ke),
                             getFailedObject(ke), ke.isFatal());
@@ -248,16 +249,17 @@
         e.setStackTrace(ke.getStackTrace());
         return e;
     }
-    
+
     /**
-     * Translate to a facade-level exception if the given exception 
-     *     a) has a cause i.e. one and only nested Throwable 
-     * and b) that cause is one of the known internal exception which has a 
-     *        direct facade-level counterpart 
-     *        (for example, ObjectNotFoundException can be translated to 
-     *         EntityNotFoundException). 
-     * If the above conditions are not met then return generic 
ArgumentException.
-     * 
+     * Translate to a facade-level exception if the given exception
+     *     a) has a cause i.e. one and only nested Throwable
+     * and b) that cause is one of the known internal exception which has a
+     *        direct facade-level counterpart
+     *        (for example, ObjectNotFoundException can be translated to
+     *         EntityNotFoundException).
+     * If the above conditions are not met then return generic
+     *    ArgumentException.
+     *
      * In either case, preserve all the details.
      */
     private static Exception translateCause(OpenJPAException ke) {

Modified: 
openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceProductDerivation.java
URL: 
http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceProductDerivation.java?rev=756066&r1=756065&r2=756066&view=diff
==============================================================================
--- 
openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceProductDerivation.java
 (original)
+++ 
openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceProductDerivation.java
 Thu Mar 19 16:03:15 2009
@@ -40,6 +40,7 @@
 import org.apache.openjpa.conf.OpenJPAConfigurationImpl;
 import org.apache.openjpa.conf.OpenJPAProductDerivation;
 import org.apache.openjpa.conf.Specification;
+import org.apache.openjpa.kernel.MixedLockLevels;
 import org.apache.openjpa.lib.conf.AbstractProductDerivation;
 import org.apache.openjpa.lib.conf.Configuration;
 import org.apache.openjpa.lib.conf.ConfigurationProvider;
@@ -110,29 +111,29 @@
         conf.addValue(new EntityManagerFactoryValue());
         
         conf.readLockLevel.setAlias("optimistic", String
-            .valueOf(JPA2LockLevels.LOCK_OPTIMISTIC));
+            .valueOf(MixedLockLevels.LOCK_OPTIMISTIC));
         conf.readLockLevel.setAlias("optimistic-force-increment", String
-            .valueOf(JPA2LockLevels.LOCK_OPTIMISTIC_FORCE_INCREMENT));
+            .valueOf(MixedLockLevels.LOCK_OPTIMISTIC_FORCE_INCREMENT));
         conf.readLockLevel.setAlias("pessimistic-read", String
-            .valueOf(JPA2LockLevels.LOCK_PESSIMISTIC_READ));
+            .valueOf(MixedLockLevels.LOCK_PESSIMISTIC_READ));
         conf.readLockLevel.setAlias("pessimistic-write", String
-            .valueOf(JPA2LockLevels.LOCK_PESSIMISTIC_WRITE));
+            .valueOf(MixedLockLevels.LOCK_PESSIMISTIC_WRITE));
         conf.readLockLevel.setAlias("pessimistic-force-increment", String
-            .valueOf(JPA2LockLevels.LOCK_PESSIMISTIC_FORCE_INCREMENT));
+            .valueOf(MixedLockLevels.LOCK_PESSIMISTIC_FORCE_INCREMENT));
 
         conf.writeLockLevel.setAlias("optimistic", String
-            .valueOf(JPA2LockLevels.LOCK_OPTIMISTIC));
+            .valueOf(MixedLockLevels.LOCK_OPTIMISTIC));
         conf.writeLockLevel.setAlias("optimistic-force-increment", String
-            .valueOf(JPA2LockLevels.LOCK_OPTIMISTIC_FORCE_INCREMENT));
+            .valueOf(MixedLockLevels.LOCK_OPTIMISTIC_FORCE_INCREMENT));
         conf.writeLockLevel.setAlias("pessimistic-read", String
-            .valueOf(JPA2LockLevels.LOCK_PESSIMISTIC_READ));
+            .valueOf(MixedLockLevels.LOCK_PESSIMISTIC_READ));
         conf.writeLockLevel.setAlias("pessimistic-write", String
-            .valueOf(JPA2LockLevels.LOCK_PESSIMISTIC_WRITE));
+            .valueOf(MixedLockLevels.LOCK_PESSIMISTIC_WRITE));
         conf.writeLockLevel.setAlias("pessimistic-force-increment", String
-            .valueOf(JPA2LockLevels.LOCK_PESSIMISTIC_FORCE_INCREMENT));
+            .valueOf(MixedLockLevels.LOCK_PESSIMISTIC_FORCE_INCREMENT));
 
         conf.lockManagerPlugin.setAlias("mixed",
-            JPA2LockManager.class.getName());
+            "org.apache.openjpa.jdbc.kernel.MixedLockManager");
 
         return true;
     }
@@ -633,7 +634,8 @@
                 return;
 
             switch (name.charAt(0)) {
-                // cases 'name' and 'transaction-type' are handled in 
startPersistenceUnit()
+                // cases 'name' and 'transaction-type' are handled in
+                //      startPersistenceUnit()
                 // case 'property' for 'properties' is handled in 
startElement()
                 case 'c': // class
                     _info.addManagedClassName(currentText());

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=756066&r1=756065&r2=756066&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
 Thu Mar 19 16:03:15 2009
@@ -167,7 +167,5 @@
 non-unique-result: Query "{0}" selected {1} results, but expected unique 
result.
 unwrap-em-invalid: EntityManager can not be unwrapped to an instance of "{0}".
 unwrap-query-invalid: Query can not be unwrapped to an instance of "{0}".
-optimistic-violation-lock: An optimistic lock violation was detected when \
-    locking object instance.
 invalid_entity_argument: Object being locked must be an valid and not detached 
\
     entity.

Modified: openjpa/trunk/openjpa-project/src/doc/manual/ref_guide_runtime.xml
URL: 
http://svn.apache.org/viewvc/openjpa/trunk/openjpa-project/src/doc/manual/ref_guide_runtime.xml?rev=756066&r1=756065&r2=756066&view=diff
==============================================================================
--- openjpa/trunk/openjpa-project/src/doc/manual/ref_guide_runtime.xml 
(original)
+++ openjpa/trunk/openjpa-project/src/doc/manual/ref_guide_runtime.xml Thu Mar 
19 16:03:15 2009
@@ -526,7 +526,10 @@
 openjpa.ReadLockLevel</literal></link> and
 <link 
linkend="openjpa.WriteLockLevel"><literal>openjpa.WriteLockLevel</literal>
 </link> configuration properties. Each property accepts a value of <literal>
-none</literal>, <literal>read</literal>, <literal>write</literal>, or a number
+none</literal>, <literal>read</literal>, <literal>write</literal>, 
+<literal>optimistic</literal>, <literal>optimistic-force-increment</literal>,
+<literal>pessimistic-read</literal>, <literal>pessimistic-write</literal>,
+<literal>pessimistic-force-increment</literal>, or a number
 corresponding to a lock level defined by the
 <link linkend="ref_guide_locking_lockmgr">lock manager</link> in use. These
 properties apply only to non-optimistic transactions; during optimistic
@@ -729,12 +732,12 @@
                 <listitem>
                     <para>
 <literal>mixed</literal>: This is an alias for the
-<ulink url="../javadoc/org/apache/openjpa/persistence/JPA2LockManager.html">
-<classname>org.apache.openjpa.persistence.JPA2LockManager</classname>
+<ulink url="../javadoc/org/apache/openjpa/jdbc/kernel/MixedLockManager.html">
+<classname>org.apache.openjpa.jdbc.kernel.MixedLockManager</classname>
 </ulink>, which implements the JPA 2.0 specification entity locking behaviors.
 It combines both the optimistic and pessimistic semantics controlled by
-lock modes argument in methods define in the entity manager
-and query interfaces or OpenJPA lock level properties.
+lock mode argument in methods define in the EntityManager
+and Query interfaces or OpenJPA lock level properties.
                     </para>
                     <para>
 The <literal>mixed</literal> LockManager inherits all the properties available
@@ -743,7 +746,7 @@
 <literal>VersionUpdateOnWriteLock</literal> properties.
                     </para>
                     <para>
-This is the default <literal>openjpa.LockManager</literal> setting in JPA.
+This is the default <literal>openjpa.LockManager</literal> setting in OpenJPA.
                     </para>
                 </listitem>
                 <listitem>


Reply via email to