openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From p..@apache.org
Subject svn commit: r526266 - in /incubator/openjpa/trunk: openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/ openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/ openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/ openjpa-pe...
Date Fri, 06 Apr 2007 19:50:54 GMT
Author: pcl
Date: Fri Apr  6 12:50:53 2007
New Revision: 526266

URL: http://svn.apache.org/viewvc?view=rev&rev=526266
Log:
OPENJPA-182. forUpdateClause is now used even if forUpdate is false, to allow for read-only
optimizations. Changed JDBCFetchPlan.setIsolationLevel and JDBCFetchConfiguration.setIsolationLevel
to just JDBCFetchXXX.setIsolation.

Modified:
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/DelegatingJDBCFetchConfiguration.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/JDBCFetchConfiguration.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/JDBCFetchConfigurationImpl.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/HSQLDictionary.java
    incubator/openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/JDBCFetchPlan.java
    incubator/openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/JDBCFetchPlanImpl.java
    incubator/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/TestIsolationLevelOverride.java

Modified: incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/DelegatingJDBCFetchConfiguration.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/DelegatingJDBCFetchConfiguration.java?view=diff&rev=526266&r1=526265&r2=526266
==============================================================================
--- incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/DelegatingJDBCFetchConfiguration.java
(original)
+++ incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/DelegatingJDBCFetchConfiguration.java
Fri Apr  6 12:50:53 2007
@@ -241,17 +241,17 @@
         }
     }
 
-    public int getIsolationLevel() {
+    public int getIsolation() {
         try {
-            return getJDBCDelegate().getIsolationLevel();
+            return getJDBCDelegate().getIsolation();
         } catch (RuntimeException re) {
             throw translate(re);
         }
     }
 
-    public JDBCFetchConfiguration setIsolationLevel(int level) {
+    public JDBCFetchConfiguration setIsolation(int level) {
         try {
-            getJDBCDelegate().setIsolationLevel(level);
+            getJDBCDelegate().setIsolation(level);
             return this;
         } catch (RuntimeException re) {
             throw translate(re);

Modified: incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/JDBCFetchConfiguration.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/JDBCFetchConfiguration.java?view=diff&rev=526266&r1=526265&r2=526266
==============================================================================
--- incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/JDBCFetchConfiguration.java
(original)
+++ incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/JDBCFetchConfiguration.java
Fri Apr  6 12:50:53 2007
@@ -186,7 +186,7 @@
      *
      * @since 0.9.7
      */
-    public int getIsolationLevel();
+    public int getIsolation();
 
     /**
      * <p>The isolation level for queries issued to the database. This overrides
@@ -203,5 +203,5 @@
      *
      * @since 0.9.7
      */
-    public JDBCFetchConfiguration setIsolationLevel(int level);
+    public JDBCFetchConfiguration setIsolation(int level);
 }

Modified: incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/JDBCFetchConfigurationImpl.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/JDBCFetchConfigurationImpl.java?view=diff&rev=526266&r1=526265&r2=526266
==============================================================================
--- incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/JDBCFetchConfigurationImpl.java
(original)
+++ incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/JDBCFetchConfigurationImpl.java
Fri Apr  6 12:50:53 2007
@@ -322,11 +322,11 @@
         return (JDBCConfiguration) conf;
     }
 
-    public int getIsolationLevel() {
+    public int getIsolation() {
         return _state.isolationLevel;
     }
 
-    public JDBCFetchConfiguration setIsolationLevel(int level) {
+    public JDBCFetchConfiguration setIsolation(int level) {
         if (level != -1 && level != DEFAULT
             && level != Connection.TRANSACTION_NONE
             && level != Connection.TRANSACTION_READ_UNCOMMITTED

Modified: incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java?view=diff&rev=526266&r1=526265&r2=526266
==============================================================================
--- incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java
(original)
+++ incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java
Fri Apr  6 12:50:53 2007
@@ -24,7 +24,6 @@
 import org.apache.openjpa.jdbc.kernel.JDBCFetchConfiguration;
 import org.apache.openjpa.jdbc.schema.Sequence;
 import org.apache.openjpa.util.OpenJPAException;
-import org.apache.openjpa.kernel.LockLevels;
 
 /**
  * Dictionary for IBM DB2 database.
@@ -238,8 +237,8 @@
         try {
             // Determine the isolationLevel; the fetch
             // configuration data overrides the persistence.xml value
-            if (fetch != null && fetch.getIsolationLevel() != -1)
-                isolationLevel = fetch.getIsolationLevel();
+            if (fetch != null && fetch.getIsolation() != -1)
+                isolationLevel = fetch.getIsolation();
             else
                 isolationLevel = conf.getTransactionIsolationConstant();
 

Modified: incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java?view=diff&rev=526266&r1=526265&r2=526266
==============================================================================
--- incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
(original)
+++ incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
Fri Apr  6 12:50:53 2007
@@ -2145,7 +2145,7 @@
         SQLBuffer having, SQLBuffer order,
         boolean distinct, boolean forUpdate, long start, long end) {
         return toOperation(getSelectOperation(fetch), selects, from, where,
-            group, having, order, distinct, forUpdate, start, end,
+            group, having, order, distinct, start, end,
             getForUpdateClause(fetch, forUpdate));
     }
 
@@ -2155,12 +2155,16 @@
      */
     protected String getForUpdateClause(JDBCFetchConfiguration fetch,
         boolean forUpdate) {
-        if (fetch != null && fetch.getIsolationLevel() != -1)
+        if (fetch != null && fetch.getIsolation() != -1) {
             throw new IllegalStateException(_loc.get(
                 "isolation-level-config-not-supported", getClass().getName())
                 .getMessage());
-        else
+        } else if (forUpdate && !simulateLocking) {
+            assertSupport(supportsSelectForUpdate, "SupportsSelectForUpdate");
             return forUpdateClause;
+        } else {
+            return null;
+        }
     }
 
     /**
@@ -2175,8 +2179,8 @@
      */
     protected SQLBuffer toOperation(String op, SQLBuffer selects,
         SQLBuffer from, SQLBuffer where, SQLBuffer group, SQLBuffer having,
-        SQLBuffer order, boolean distinct, boolean forUpdate, long start,
-        long end, String forUpdateClause) {
+        SQLBuffer order, boolean distinct, long start, long end,
+        String forUpdateClause) {
         SQLBuffer buf = new SQLBuffer(this);
         buf.append(op);
 
@@ -2202,12 +2206,8 @@
             buf.append(" ORDER BY ").append(order);
         if (range && rangePosition == RANGE_POST_SELECT)
             appendSelectRange(buf, start, end);
-
-        if (forUpdate && !simulateLocking) {
-            assertSupport(supportsSelectForUpdate, "SupportsSelectForUpdate");
-            if (forUpdateClause != null)
-                buf.append(" ").append(forUpdateClause);
-        }
+        if (forUpdateClause != null)
+            buf.append(" ").append(forUpdateClause);
         if (range && rangePosition == RANGE_POST_LOCK)
             appendSelectRange(buf, start, end);
         return buf;

Modified: incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/HSQLDictionary.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/HSQLDictionary.java?view=diff&rev=526266&r1=526265&r2=526266
==============================================================================
--- incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/HSQLDictionary.java
(original)
+++ incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/HSQLDictionary.java
Fri Apr  6 12:50:53 2007
@@ -192,14 +192,14 @@
 
     protected SQLBuffer toOperation(String op, SQLBuffer selects,
         SQLBuffer from, SQLBuffer where, SQLBuffer group, SQLBuffer having,
-        SQLBuffer order, boolean distinct, boolean forUpdate, long start,
-        long end, String forUpdateClause) {
+        SQLBuffer order, boolean distinct, long start, long end,
+        String forUpdateClause) {
         // hsql requires ordering when limit is used
         if ((start != 0 || end != Long.MAX_VALUE)
             && (order == null || order.isEmpty()))
             order = _oneBuffer;
         return super.toOperation(op, selects, from, where, group, having,
-            order, distinct, forUpdate, start, end, forUpdateClause);
+            order, distinct, start, end, forUpdateClause);
     }
 
     public Column[] getColumns(DatabaseMetaData meta, String catalog,

Modified: incubator/openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/JDBCFetchPlan.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/JDBCFetchPlan.java?view=diff&rev=526266&r1=526265&r2=526266
==============================================================================
--- incubator/openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/JDBCFetchPlan.java
(original)
+++ incubator/openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/JDBCFetchPlan.java
Fri Apr  6 12:50:53 2007
@@ -132,7 +132,7 @@
      *
      * @since 0.9.7
      */
-    public int getIsolationLevel();
+    public int getIsolation();
 
     /**
      * <p>The isolation level for queries issued to the database. This overrides
@@ -149,5 +149,5 @@
      *
      * @since 0.9.7
      */
-    public JDBCFetchPlan setIsolationLevel(int level);
+    public JDBCFetchPlan setIsolation(int level);
 }

Modified: incubator/openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/JDBCFetchPlanImpl.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/JDBCFetchPlanImpl.java?view=diff&rev=526266&r1=526265&r2=526266
==============================================================================
--- incubator/openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/JDBCFetchPlanImpl.java
(original)
+++ incubator/openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/JDBCFetchPlanImpl.java
Fri Apr  6 12:50:53 2007
@@ -103,12 +103,12 @@
         return this;
     }
 
-    public int getIsolationLevel() {
-        return _fetch.getIsolationLevel();
+    public int getIsolation() {
+        return _fetch.getIsolation();
     }
 
-    public JDBCFetchPlan setIsolationLevel(int level) {
-        _fetch.setIsolationLevel(level);
+    public JDBCFetchPlan setIsolation(int level) {
+        _fetch.setIsolation(level);
         return this;
     }
 }

Modified: incubator/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/TestIsolationLevelOverride.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/TestIsolationLevelOverride.java?view=diff&rev=526266&r1=526265&r2=526266
==============================================================================
--- incubator/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/TestIsolationLevelOverride.java
(original)
+++ incubator/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/TestIsolationLevelOverride.java
Fri Apr  6 12:50:53 2007
@@ -16,14 +16,11 @@
 package org.apache.openjpa.persistence.jdbc;
 
 import java.sql.Connection;
-import javax.persistence.EntityManager;
-import javax.persistence.LockModeType;
 import javax.persistence.PersistenceException;
 
 import org.apache.openjpa.persistence.test.SQLListenerTestCase;
 import org.apache.openjpa.persistence.simple.AllFieldTypes;
 import org.apache.openjpa.persistence.OpenJPAPersistence;
-import org.apache.openjpa.persistence.FetchPlan;
 import org.apache.openjpa.persistence.OpenJPAEntityManager;
 import org.apache.openjpa.jdbc.sql.DBDictionary;
 import org.apache.openjpa.jdbc.sql.DB2Dictionary;
@@ -53,7 +50,7 @@
         try {
             em.getTransaction().begin();
             ((JDBCFetchPlan) em.getFetchPlan())
-                .setIsolationLevel(Connection.TRANSACTION_SERIALIZABLE);
+                .setIsolation(Connection.TRANSACTION_SERIALIZABLE);
             em.find(AllFieldTypes.class, 0);
 
             if (dict instanceof DB2Dictionary) {



Mime
View raw message