Author: wisneskid
Date: Fri Apr 20 10:24:32 2007
New Revision: 530860

URL: http://svn.apache.org/viewvc?view=rev&rev=530860
Log:
OPENJPA-222 clean up

Modified:
    
incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java
    
incubator/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/TestIsolationLevelOverride.java
    
incubator/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/TestSelectForUpdateOverride.java

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=530860&r1=530859&r2=530860
==============================================================================
--- 
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 20 10:24:32 2007
@@ -37,11 +37,11 @@
     public String optimizeClause = "optimize for";
     public String rowClause = "row";
     private int db2ServerType = 0;
-    private static final int db2ISeriesV5R3AndEarlier = 1;
+    private static final int db2ISeriesV5R3OrEarlier = 1;
     private static final int db2UDBV81OrEarlier = 2;
     private static final int db2ZOSV8xOrLater = 3;
-    private static final int db2UDBV82AndLater = 4;
-    private static final int db2ISeriesV5R4AndLater = 5;
+    private static final int db2UDBV82OrLater = 4;
+    private static final int db2ISeriesV5R4OrLater = 5;
        private static final String forUpdateOfClause = "FOR UPDATE OF";
     private static final String withRSClause = "WITH RS";
     private static final String withRRClause = "WITH RR";
@@ -191,16 +191,16 @@
                int min = metaData.getDatabaseMinorVersion();
 
                // Determine the type of DB2 database
-               if (isDB2ISeriesV5R3AndEarlier(metaData))
-                   db2ServerType = db2ISeriesV5R3AndEarlier;
+               if (isDB2ISeriesV5R3OrEarlier(metaData))
+                   db2ServerType = db2ISeriesV5R3OrEarlier;
                else if (isDB2UDBV81OrEarlier(metaData,maj,min))
                    db2ServerType = db2UDBV81OrEarlier;
                else if (isDB2ZOSV8xOrLater(metaData,maj))
                    db2ServerType = db2ZOSV8xOrLater;
-               else if (isDB2UDBV82AndLater(metaData,maj,min))
-                   db2ServerType = db2UDBV82AndLater;
-               else if (isDB2ISeriesV5R4AndLater(metaData))
-                   db2ServerType = db2ISeriesV5R4AndLater;
+               else if (isDB2UDBV82OrLater(metaData,maj,min))
+                   db2ServerType = db2UDBV82OrLater;
+               else if (isDB2ISeriesV5R4OrLater(metaData))
+                   db2ServerType = db2ISeriesV5R4OrLater;
 
                if (maj >= 9 || (maj == 8 && min >= 2)) {
                        supportsLockingWithMultipleTables = true;
@@ -247,7 +247,7 @@
 
             if (forUpdate) {
                 switch(db2ServerType) {
-                case db2ISeriesV5R3AndEarlier:
+                case db2ISeriesV5R3OrEarlier:
                 case db2UDBV81OrEarlier:
                     if (isolationLevel ==
                         Connection.TRANSACTION_READ_UNCOMMITTED) {
@@ -257,7 +257,7 @@
                         forUpdateString.append(" ").append(forUpdateOfClause);
                     break;
                 case db2ZOSV8xOrLater:
-                case db2UDBV82AndLater:
+                case db2UDBV82OrLater:
                     if (isolationLevel == Connection.TRANSACTION_SERIALIZABLE) 
{
                         forUpdateString.append(" ").append(forReadOnlyClause)
                             .append(" ").append(withRRClause)
@@ -268,7 +268,7 @@
                             .append(" ").append(useKeepUpdateLockClause);      
                      
                     }
                     break;
-                case db2ISeriesV5R4AndLater:
+                case db2ISeriesV5R4OrLater:
                     if (isolationLevel == Connection.TRANSACTION_SERIALIZABLE) 
{
                         forUpdateString.append(" ").append(forReadOnlyClause)
                             .append(" ").append(withRRClause)
@@ -289,7 +289,7 @@
         return forUpdateString.toString();
     }
 
-    public boolean isDB2UDBV82AndLater(DatabaseMetaData metadata, int maj,
+    public boolean isDB2UDBV82OrLater(DatabaseMetaData metadata, int maj,
         int min) throws SQLException {
         boolean match = false;
         if (metadata.getDatabaseProductVersion().indexOf("SQL") != -1
@@ -307,7 +307,7 @@
         return match;
     }
 
-    public boolean isDB2ISeriesV5R3AndEarlier(DatabaseMetaData metadata)
+    public boolean isDB2ISeriesV5R3OrEarlier(DatabaseMetaData metadata)
        throws SQLException {
        boolean match = false;
        if (metadata.getDatabaseProductVersion().indexOf("AS") != -1
@@ -317,7 +317,7 @@
        return match;
     }
 
-    public boolean isDB2ISeriesV5R4AndLater(DatabaseMetaData metadata)
+    public boolean isDB2ISeriesV5R4OrLater(DatabaseMetaData metadata)
        throws SQLException {
        boolean match = false;
        if (metadata.getDatabaseProductVersion().indexOf("AS") != -1

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=530860&r1=530859&r2=530860
==============================================================================
--- 
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 20 10:24:32 2007
@@ -68,7 +68,7 @@
             em.getTransaction().begin();
             if (useHintsAndQueries) {
                 Query q = em.createQuery(
-                    "select o from AllFieldTypes o where o.intField = :p");
+                "select o from AllFieldTypes o where o.intField = :p");
                 q.setParameter("p", 0);
                 if (useStringHints) {
                     q.setHint("openjpa.FetchPlan.Isolation", "SERIALIZABLE");
@@ -82,89 +82,88 @@
                         .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");
+                if (dict instanceof DB2Dictionary) {
+                    if ((((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 ((((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 (((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 {
+                        fail("OpenJPA currently only supports " 
+                            +"per-query isolation level configuration on the" 
+                            +" following databases: DB2");
+                    }
                 }    
-                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 &&((((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");
+                if (dict instanceof DB2Dictionary ) {
+                    if ((((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 ((((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 (((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 {
+                        fail("OpenJPA currently only supports per-query" 
+                            +" isolation level configuration on the following" 
+                            +" databases: DB2");
+                    }
                 }    
-                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/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/TestSelectForUpdateOverride.java
URL: 
http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/TestSelectForUpdateOverride.java?view=diff&rev=530860&r1=530859&r2=530860
==============================================================================
--- 
incubator/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/TestSelectForUpdateOverride.java
 (original)
+++ 
incubator/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/TestSelectForUpdateOverride.java
 Fri Apr 20 10:24:32 2007
@@ -57,47 +57,46 @@
             OpenJPAPersistence.cast(em).getFetchPlan()
                 .setReadLockMode(LockModeType.WRITE);
             em.find(AllFieldTypes.class, 0);
-
             assertEquals(1, sql.size());
-            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");
+            if (dict instanceof DB2Dictionary) {
+                if ((((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 ((((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 (((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 {
+                    fail("OpenJPA currently only supports per-query isolation 
" 
+                        + "level configuration on the following databases: "
+                        + "DB2");
+                }
             }    
-            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();


Reply via email to