You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openjpa.apache.org by jr...@apache.org on 2010/03/01 22:29:02 UTC

svn commit: r917727 - in /openjpa/trunk/openjpa-jdbc/src/main: java/org/apache/openjpa/jdbc/sql/InformixDictionary.java resources/org/apache/openjpa/jdbc/sql/localizer.properties

Author: jrbauer
Date: Mon Mar  1 21:29:01 2010
New Revision: 917727

URL: http://svn.apache.org/viewvc?rev=917727&view=rev
Log:
OPENJPA-1540 Modified Informix dictionary to detect non-delimited identifier case for the Informix driver.  Also added missing method override.

Modified:
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/InformixDictionary.java
    openjpa/trunk/openjpa-jdbc/src/main/resources/org/apache/openjpa/jdbc/sql/localizer.properties

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/InformixDictionary.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/InformixDictionary.java?rev=917727&r1=917726&r2=917727&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/InformixDictionary.java (original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/InformixDictionary.java Mon Mar  1 21:29:01 2010
@@ -29,6 +29,7 @@
 import java.util.Collection;
 import java.util.Set;
 
+import org.apache.openjpa.jdbc.identifier.DBIdentifier;
 import org.apache.openjpa.jdbc.identifier.DBIdentifier.DBIdentifierType;
 import org.apache.openjpa.jdbc.kernel.exps.FilterValue;
 import org.apache.openjpa.jdbc.schema.Column;
@@ -167,11 +168,13 @@
             { 
                 driverVendor = VENDOR_IBM;
                 useJCC = true;
-                try {
-                    if (meta.storesLowerCaseIdentifiers()) 
-                        schemaCase = SCHEMA_CASE_LOWER;
-                } catch (SQLException e) {}
-            } else if ("Informix".equalsIgnoreCase(driverName))
+                setIdentifierCase(meta);
+            } 
+            else if (driverName.equals("IBM Informix JDBC Driver for IBM Informix Dynamic Server")) {
+                setIdentifierCase(meta);
+                driverVendor = VENDOR_IBM;
+            }
+            else if ("Informix".equalsIgnoreCase(driverName))
                 driverVendor = VENDOR_DATADIRECT;
             else
                 driverVendor = VENDOR_OTHER;
@@ -186,11 +189,40 @@
                     conn.getTransactionIsolation()}));
         }
     }
+    
+    private void setIdentifierCase(DatabaseMetaData meta) {
+        try {
+            // lower case identifiers is the default for the JCC and newer
+            // Informix JDBC drivers
+            if (meta.storesLowerCaseIdentifiers()) { 
+                schemaCase = SCHEMA_CASE_LOWER;
+            }
+            else if (meta.storesMixedCaseIdentifiers()) {
+                schemaCase = SCHEMA_CASE_PRESERVE;
+            }
+            // otherwise, use the default (upper)
+        }
+        catch (SQLException e) {
+            getLog().warn("cannot-determine-identifier-base-case");
+            if (getLog().isTraceEnabled()) {
+                getLog().trace(e.toString(), e);
+            }
+        }
+    }
 
     @Override
     public Column[] getColumns(DatabaseMetaData meta, String catalog,
         String schemaName, String tableName, String columnName, Connection conn)
         throws SQLException {
+        return getColumns(meta, DBIdentifier.newCatalog(catalog), 
+            DBIdentifier.newSchema(schemaName),DBIdentifier.newTable(tableName),
+            DBIdentifier.newColumn(columnName), conn);
+    }
+
+    @Override
+    public Column[] getColumns(DatabaseMetaData meta, DBIdentifier catalog,
+        DBIdentifier schemaName, DBIdentifier tableName, DBIdentifier columnName, Connection conn)
+        throws SQLException {
         Column[] cols = super.getColumns(meta, catalog, schemaName, tableName,
             columnName, conn);
 

Modified: openjpa/trunk/openjpa-jdbc/src/main/resources/org/apache/openjpa/jdbc/sql/localizer.properties
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/resources/org/apache/openjpa/jdbc/sql/localizer.properties?rev=917727&r1=917726&r2=917727&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/resources/org/apache/openjpa/jdbc/sql/localizer.properties (original)
+++ openjpa/trunk/openjpa-jdbc/src/main/resources/org/apache/openjpa/jdbc/sql/localizer.properties Mon Mar  1 21:29:01 2010
@@ -204,4 +204,6 @@
     identifiers.  The default value of "preserve" will be used.
 unknown-delim-support: Unable to determine whether delimited identifiers are supported. \
     The use of delimiters will not be supported.
-can_not_get_current_schema: Unable to get current schema. SQLException message is "{0}".
\ No newline at end of file
+can_not_get_current_schema: Unable to get current schema. SQLException message is "{0}".
+cannot-determine-identifier-base-case: Unable to determine the case to use for \
+    identifiers.  The default value of "{0}" will be used.