openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mik...@apache.org
Subject svn commit: r530827 - in /incubator/openjpa/branches/0.9.7-incubating-RC2: openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/ openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/ openjpa-persistence-jdbc/src/test/resources/o...
Date Fri, 20 Apr 2007 14:34:49 GMT
Author: mikedd
Date: Fri Apr 20 07:34:48 2007
New Revision: 530827

URL: http://svn.apache.org/viewvc?view=rev&rev=530827
Log:
OpenJPA-222 and copyright fixes for RC2.

Modified:
    incubator/openjpa/branches/0.9.7-incubating-RC2/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java
    incubator/openjpa/branches/0.9.7-incubating-RC2/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/TestIsolationLevelOverride.java
    incubator/openjpa/branches/0.9.7-incubating-RC2/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/TestSelectForUpdateOverride.java
    incubator/openjpa/branches/0.9.7-incubating-RC2/openjpa-persistence-jdbc/src/test/resources/org/apache/openjpa/persistence/xml/orm.xml
    incubator/openjpa/branches/0.9.7-incubating-RC2/openjpa-project/CHANGES.txt
    incubator/openjpa/branches/0.9.7-incubating-RC2/openjpa-project/RELEASE-NOTES.html

Modified: incubator/openjpa/branches/0.9.7-incubating-RC2/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/branches/0.9.7-incubating-RC2/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java?view=diff&rev=530827&r1=530826&r2=530827
==============================================================================
--- incubator/openjpa/branches/0.9.7-incubating-RC2/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java
(original)
+++ incubator/openjpa/branches/0.9.7-incubating-RC2/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java
Fri Apr 20 07:34:48 2007
@@ -39,7 +39,7 @@
     private int db2ServerType = 0;
     private static final int db2ISeriesV5R3AndEarlier = 1;
     private static final int db2UDBV81OrEarlier = 2;
-    private static final int db2ZOSV8x = 3;
+    private static final int db2ZOSV8xOrLater = 3;
     private static final int db2UDBV82AndLater = 4;
     private static final int db2ISeriesV5R4AndLater = 5;
 	private static final String forUpdateOfClause = "FOR UPDATE OF";
@@ -195,8 +195,8 @@
 	    	    db2ServerType = db2ISeriesV5R3AndEarlier;
 	    	else if (isDB2UDBV81OrEarlier(metaData,maj,min))
 	    	    db2ServerType = db2UDBV81OrEarlier;
-	    	else if (isDB2ZOSV8x(metaData,maj))
-	    	    db2ServerType = db2ZOSV8x;
+	    	else if (isDB2ZOSV8xOrLater(metaData,maj))
+	    	    db2ServerType = db2ZOSV8xOrLater;
 	    	else if (isDB2UDBV82AndLater(metaData,maj,min))
 	    	    db2ServerType = db2UDBV82AndLater;
 	    	else if (isDB2ISeriesV5R4AndLater(metaData))
@@ -245,45 +245,38 @@
             else
                 isolationLevel = conf.getTransactionIsolationConstant();
 
-            if (!forUpdate) {
-                // This sql is not for update so add FOR Read Only clause
-                forUpdateString.append(" ").append(forReadOnlyClause)
-                    .append(" ");
-            } else {
-
+            if (forUpdate) {
                 switch(db2ServerType) {
                 case db2ISeriesV5R3AndEarlier:
                 case db2UDBV81OrEarlier:
                     if (isolationLevel ==
                         Connection.TRANSACTION_READ_UNCOMMITTED) {
                         forUpdateString.append(" ").append(withRSClause)
-                            .append(" ").append(forUpdateOfClause).append(" ");
-                    } else {
-                        forUpdateString.append(" ").append(forUpdateOfClause)
-                           .append(" ");
-                    }
+                            .append(" ").append(forUpdateOfClause);
+                    } else
+                        forUpdateString.append(" ").append(forUpdateOfClause);
                     break;
-                case db2ZOSV8x:
+                case db2ZOSV8xOrLater:
                 case db2UDBV82AndLater:
                     if (isolationLevel == Connection.TRANSACTION_SERIALIZABLE) {
-                        forUpdateString.append(" ").append(withRRClause)
-                            .append(" ").append(useKeepUpdateLockClause)
-                            .append(" ");
+                        forUpdateString.append(" ").append(forReadOnlyClause)
+                            .append(" ").append(withRRClause)
+                            .append(" ").append(useKeepUpdateLockClause);   
                     } else {
-                        forUpdateString.append(" ").append(withRSClause)
-                            .append(" ").append(useKeepUpdateLockClause)
-                            .append(" ");
+                        forUpdateString.append(" ").append(forReadOnlyClause)
+                            .append(" ").append(withRSClause)
+                            .append(" ").append(useKeepUpdateLockClause);               
            
                     }
                     break;
                 case db2ISeriesV5R4AndLater:
                     if (isolationLevel == Connection.TRANSACTION_SERIALIZABLE) {
-                        forUpdateString.append(" ").append(withRRClause)
-                            .append(" ").append(useKeepExclusiveLockClause)
-                            .append(" ");
+                        forUpdateString.append(" ").append(forReadOnlyClause)
+                            .append(" ").append(withRRClause)
+                            .append(" ").append(useKeepExclusiveLockClause);       
                     } else {
-                        forUpdateString.append(" ").append(withRSClause)
-                            .append(" ").append(useKeepExclusiveLockClause)
-                            .append(" ");
+                        forUpdateString.append(" ").append(forReadOnlyClause)
+                            .append(" ").append(withRSClause)
+                            .append(" ").append(useKeepExclusiveLockClause);
                     }
                     break;
                 }
@@ -305,11 +298,11 @@
         return match;
     }
 
-    public boolean isDB2ZOSV8x(DatabaseMetaData metadata, int maj)
+    public boolean isDB2ZOSV8xOrLater(DatabaseMetaData metadata, int maj)
        throws SQLException {
        boolean match = false;
        if (metadata.getDatabaseProductVersion().indexOf("DSN") != -1
-           && maj == 8)
+           && maj >= 8)
            match = true;
         return match;
     }
@@ -414,4 +407,8 @@
             return sqle.getMessage();
         }
     }
-   }
+
+    public int getDb2ServerType() {
+        return db2ServerType;
+    }
+}

Modified: incubator/openjpa/branches/0.9.7-incubating-RC2/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/TestIsolationLevelOverride.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/branches/0.9.7-incubating-RC2/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/TestIsolationLevelOverride.java?view=diff&rev=530827&r1=530826&r2=530827
==============================================================================
--- incubator/openjpa/branches/0.9.7-incubating-RC2/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/TestIsolationLevelOverride.java
(original)
+++ incubator/openjpa/branches/0.9.7-incubating-RC2/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/TestIsolationLevelOverride.java
Fri Apr 20 07:34:48 2007
@@ -82,18 +82,89 @@
                         .getIsolation());
 
                 q.getResultList();
+                if (dict instanceof DB2Dictionary &&((((DB2Dictionary)dict).
+                    getDb2ServerType() == 1) || ((DB2Dictionary)dict)
+                        .getDb2ServerType()== 2)) {
+                    assertEquals(1, sql.size());
+                    assertSQL("SELECT t0.id, t0.booleanField, t0.byteField,"
+                        + " t0.charField, t0.dateField, t0.doubleField,"
+                        + " t0.floatField, t0.intField, t0.longField, "
+                        + "t0.shortField, t0.stringField FROM "
+                        + "AllFieldTypes t0 WHERE \\(t0.intField = \\?\\) "
+                        + " FOR UPDATE OF");
+                }
+
+                // it is DB2 v82 or later
+                else if (dict instanceof DB2Dictionary &&((((DB2Dictionary)dict).
+                    getDb2ServerType() == 3) || ((DB2Dictionary)dict)
+                        .getDb2ServerType() == 4)) {
+                    assertEquals(1, sql.size());
+                    assertSQL("SELECT t0.id, t0.booleanField, t0.byteField,"
+                        + " t0.charField, t0.dateField, t0.doubleField,"
+                        + " t0.floatField, t0.intField, t0.longField, "
+                        + "t0.shortField, t0.stringField FROM "
+                        + "AllFieldTypes t0 WHERE \\(t0.intField = \\?\\) "
+                        + " FOR READ ONLY WITH RR USE AND KEEP UPDATE LOCKS");
+                }
+
+                else if (dict instanceof DB2Dictionary && ((DB2Dictionary)dict).
+                    getDb2ServerType() == 5){
+                    assertEquals(1, sql.size());
+                    assertSQL("SELECT t0.id, t0.booleanField, t0.byteField,"
+                        + " t0.charField, t0.dateField, t0.doubleField,"
+                        + " t0.floatField, t0.intField, t0.longField, "
+                        + "t0.shortField, t0.stringField FROM "
+                        + "AllFieldTypes t0 WHERE \\(t0.intField = \\?\\) "
+                        + " FOR READ ONLY WITH RR USE AND KEEP EXCLUSIVE " 
+                        + "LOCKS");
+                }    
+                else if (dict instanceof DB2Dictionary) {
+                    fail("OpenJPA currently only supports per-query isolation " 
+                    + "level configuration on the following databases: DB2");
+                }
             } else {
                 ((JDBCFetchPlan) em.getFetchPlan())
                     .setIsolation(IsolationLevel.SERIALIZABLE);
                 em.find(AllFieldTypes.class, 0);
-            }
-
-            if (dict instanceof DB2Dictionary) {
-                assertEquals(1, sql.size());
-                assertSQL(".*DB2-specific SQL to test for goes here.*");
-            } else {
-                fail("OpenJPA currently only supports per-query isolation " +
-                    "level configuration on the following databases: DB2");
+                if (dict instanceof DB2Dictionary &&((((DB2Dictionary)dict).
+                    getDb2ServerType() == 1) || ((DB2Dictionary)dict)
+                        .getDb2ServerType()== 2)) {
+                    assertEquals(1, sql.size());
+                    assertSQL("SELECT t0.booleanField, t0.byteField, "
+                        + "t0.charField, t0.dateField, t0.doubleField,"
+                        + " t0.floatField, t0.intField, t0.longField,"
+                        + " t0.shortField, t0.stringField FROM "
+                        + "AllFieldTypes t0 WHERE t0.id = \\? "
+                        + " FOR UPDATE OF optimize for 1 row");
+                }
+                // it is DB2 v82 or later
+                else if (dict instanceof DB2Dictionary &&((((DB2Dictionary)dict).
+                    getDb2ServerType() == 3) || ((DB2Dictionary)dict)
+                        .getDb2ServerType() == 4)) {
+                    assertEquals(1, sql.size());
+                    assertSQL("SELECT t0.booleanField, t0.byteField, "
+                        + "t0.charField, t0.dateField, t0.doubleField,"
+                        + " t0.floatField, t0.intField, t0.longField,"
+                        + " t0.shortField, t0.stringField FROM "
+                        + "AllFieldTypes t0 WHERE t0.id = \\? "
+                        + " FOR READ ONLY WITH RR USE AND KEEP UPDATE LOCKS" 
+                        + " optimize for 1 row");
+                }
+                else if (dict instanceof DB2Dictionary && ((DB2Dictionary)dict).
+                    getDb2ServerType() == 5) {
+                    assertEquals(1, sql.size());
+                    assertSQL("SELECT t0.booleanField, t0.byteField, "
+                        + "t0.charField, t0.dateField, t0.doubleField,"
+                        + " t0.floatField, t0.intField, t0.longField,"
+                        + " t0.shortField, t0.stringField FROM "
+                        + "AllFieldTypes t0 WHERE t0.id = \\? "
+                        + " FOR READ ONLY WITH RR USE AND KEEP EXCLUSIVE LOCKS"
+                        + " optimize for 1 row");
+                }    
+                else if (dict instanceof DB2Dictionary) {
+                    fail("OpenJPA currently only supports per-query isolation " 
+                    + "level configuration on the following databases: DB2");
+                }
             }
         } catch (InvalidStateException pe) {
             // if we're not using DB2, we expect an InvalidStateException.

Modified: incubator/openjpa/branches/0.9.7-incubating-RC2/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/TestSelectForUpdateOverride.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/branches/0.9.7-incubating-RC2/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/TestSelectForUpdateOverride.java?view=diff&rev=530827&r1=530826&r2=530827
==============================================================================
--- incubator/openjpa/branches/0.9.7-incubating-RC2/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/TestSelectForUpdateOverride.java
(original)
+++ incubator/openjpa/branches/0.9.7-incubating-RC2/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/TestSelectForUpdateOverride.java
Fri Apr 20 07:34:48 2007
@@ -26,6 +26,7 @@
 import org.apache.openjpa.persistence.OpenJPAPersistence;
 import org.apache.openjpa.persistence.FetchPlan;
 import org.apache.openjpa.persistence.OpenJPAEntityManager;
+import org.apache.openjpa.jdbc.sql.DB2Dictionary;
 import org.apache.openjpa.jdbc.sql.DBDictionary;
 import org.apache.openjpa.jdbc.sql.HSQLDictionary;
 import org.apache.openjpa.jdbc.conf.JDBCConfiguration;
@@ -58,7 +59,45 @@
             em.find(AllFieldTypes.class, 0);
 
             assertEquals(1, sql.size());
-            assertSQL(".*FOR UPDATE.*");
+            if (dict instanceof DB2Dictionary &&((((DB2Dictionary)dict).
+                getDb2ServerType() == 1) || ((DB2Dictionary)dict)
+                    .getDb2ServerType()== 2)) {
+                assertEquals(1, sql.size());
+                assertSQL("SELECT t0.booleanField, t0.byteField, "
+                    + "t0.charField, t0.dateField, t0.doubleField,"
+                    + " t0.floatField, t0.intField, t0.longField,"
+                    + " t0.shortField, t0.stringField FROM "
+                    + "AllFieldTypes t0 WHERE t0.id = \\? "
+                    + " FOR UPDATE OF optimize for 1 row");
+            }
+            // it is DB2 v82 or later
+            else if (dict instanceof DB2Dictionary &&((((DB2Dictionary)dict).
+                getDb2ServerType() == 3) || ((DB2Dictionary)dict)
+                    .getDb2ServerType() == 4)) {
+                assertEquals(1, sql.size());
+                assertSQL("SELECT t0.booleanField, t0.byteField, "
+                    + "t0.charField, t0.dateField, t0.doubleField,"
+                    + " t0.floatField, t0.intField, t0.longField,"
+                    + " t0.shortField, t0.stringField FROM "
+                    + "AllFieldTypes t0 WHERE t0.id = \\? "
+                    + " FOR READ ONLY WITH RS USE AND KEEP UPDATE LOCKS" 
+                    + " optimize for 1 row");
+            }
+            else if (dict instanceof DB2Dictionary && ((DB2Dictionary)dict).
+                getDb2ServerType() == 5) {
+                assertEquals(1, sql.size());
+                assertSQL("SELECT t0.booleanField, t0.byteField, "
+                    + "t0.charField, t0.dateField, t0.doubleField,"
+                    + " t0.floatField, t0.intField, t0.longField,"
+                    + " t0.shortField, t0.stringField FROM "
+                    + "AllFieldTypes t0 WHERE t0.id = \\? "
+                    + " FOR READ ONLY WITH RS USE AND KEEP EXCLUSIVE LOCKS"
+                    + " optimize for 1 row");
+            }    
+            else if (dict instanceof DB2Dictionary) {
+                fail("OpenJPA currently only supports per-query isolation " +
+                "level configuration on the following databases: DB2");
+            }
         } finally {
             em.getTransaction().rollback();
             em.close();

Modified: incubator/openjpa/branches/0.9.7-incubating-RC2/openjpa-persistence-jdbc/src/test/resources/org/apache/openjpa/persistence/xml/orm.xml
URL: http://svn.apache.org/viewvc/incubator/openjpa/branches/0.9.7-incubating-RC2/openjpa-persistence-jdbc/src/test/resources/org/apache/openjpa/persistence/xml/orm.xml?view=diff&rev=530827&r1=530826&r2=530827
==============================================================================
--- incubator/openjpa/branches/0.9.7-incubating-RC2/openjpa-persistence-jdbc/src/test/resources/org/apache/openjpa/persistence/xml/orm.xml
(original)
+++ incubator/openjpa/branches/0.9.7-incubating-RC2/openjpa-persistence-jdbc/src/test/resources/org/apache/openjpa/persistence/xml/orm.xml
Fri Apr 20 07:34:48 2007
@@ -1,5 +1,22 @@
 <?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
 <entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm orm_1_0.xsd"

Modified: incubator/openjpa/branches/0.9.7-incubating-RC2/openjpa-project/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/openjpa/branches/0.9.7-incubating-RC2/openjpa-project/CHANGES.txt?view=diff&rev=530827&r1=530826&r2=530827
==============================================================================
--- incubator/openjpa/branches/0.9.7-incubating-RC2/openjpa-project/CHANGES.txt (original)
+++ incubator/openjpa/branches/0.9.7-incubating-RC2/openjpa-project/CHANGES.txt Fri Apr 20
07:34:48 2007
@@ -60,6 +60,7 @@
     * [OPENJPA-202] - after invoking LRS processing in a client by calling an @LRS annotated
relationship, the next em.clear()/em.close() gets org.apache.openjpa.persistence.InvalidStateException:
You cannot transfer large result set fields from one object or field to another
     * [OPENJPA-208] - NoResultException and NonUniqueResultException are not thrown when
expected
     * [OPENJPA-214] - Need to support floating point primary keys
+    * [OPENJPA-222] - FOR READ ONLY clause getting generated for subselects
 
 ** Improvements
     * [OPENJPA-10] - persistence unit name should be default diagnostic context for standard
OpenJPA log impl

Modified: incubator/openjpa/branches/0.9.7-incubating-RC2/openjpa-project/RELEASE-NOTES.html
URL: http://svn.apache.org/viewvc/incubator/openjpa/branches/0.9.7-incubating-RC2/openjpa-project/RELEASE-NOTES.html?view=diff&rev=530827&r1=530826&r2=530827
==============================================================================
--- incubator/openjpa/branches/0.9.7-incubating-RC2/openjpa-project/RELEASE-NOTES.html (original)
+++ incubator/openjpa/branches/0.9.7-incubating-RC2/openjpa-project/RELEASE-NOTES.html Fri
Apr 20 07:34:48 2007
@@ -5,6 +5,7 @@
 
 <ul>
 <li><a href="#Overview">Overview</a></li>
+<li><a href="#License">License</a></li>
 <li><a href="#Prerequisites">Prerequisites</a></li>
 <li><a href="#Documentation">Documentation</a></li>
 <li><a href="#GetInvolved">Getting Involved</a></li>
@@ -33,6 +34,28 @@
 site: <a href="http://incubator.apache.org/openjpa/">
 http://incubator.apache.org/openjpa/</a>
 
+<h2><a name="License"></a>License</h2>
+<P>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
+
+<BR><P><a href="http://www.apache.org/licenses/LICENSE-2.0">
+http://www.apache.org/licenses/LICENSE-2.0</a>
+
+<BR><P>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.
+
+<BR><P>The license may also be found in LICENSE.txt which is included 
+in each release of OpenJPA. 
+
 <h2><a name="Prerequisites"></a>Prerequisites</h2>
 <P>
 OpenJPA requires Java 1.5 but will not compile with Java 6. For more
@@ -135,6 +158,7 @@
 <li>[<a href='https://issues.apache.org/jira/browse/OPENJPA-202'>OPENJPA-202</a>]
- after invoking LRS processing in a client by calling an @LRS annotated relationship, the
next em.clear()/em.close() gets org.apache.openjpa.persistence.InvalidStateException: You
cannot transfer large result set fields from one object or field to another</li>
 <li>[<a href='https://issues.apache.org/jira/browse/OPENJPA-208'>OPENJPA-208</a>]
- NoResultException and NonUniqueResultException are not thrown when expected</li>
 <li>[<a href='https://issues.apache.org/jira/browse/OPENJPA-214'>OPENJPA-214</a>]
- Need to support floating point primary keys</li>
+<li>[<a href='https://issues.apache.org/jira/browse/OPENJPA-214'>OPENJPA-222</a>]
- FOR READ ONLY clause getting generated for subselects</li>
 </ul>
     
 <h2><a name="Improvements"</a>Improvements</h2>



Mime
View raw message