You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openjpa.apache.org by fa...@apache.org on 2008/12/09 19:49:50 UTC

svn commit: r724817 - /openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingInfo.java

Author: fancy
Date: Tue Dec  9 10:49:49 2008
New Revision: 724817

URL: http://svn.apache.org/viewvc?rev=724817&view=rev
Log:
OPENJPA-795  enhancer throws an exception when parsing column name "first.name" because it thinks 'first' is a table name
In U2 database column name may contain '.'

Modified:
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingInfo.java

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingInfo.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingInfo.java?rev=724817&r1=724816&r2=724817&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingInfo.java (original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingInfo.java Tue Dec  9 10:49:49 2008
@@ -492,9 +492,10 @@
         }
 
         String fullName;
-        int dotIdx = given.lastIndexOf('.');
+        String sep = repos.getDBDictionary().catalogSeparator;
+        int dotIdx = given.lastIndexOf(sep);
         if (dotIdx == -1)
-            fullName = (schemaName == null) ? given : schemaName + "." + given;
+            fullName = (schemaName == null) ? given : schemaName + sep + given;
         else {
             fullName = given;
             schema = null;
@@ -626,12 +627,15 @@
             throw new MetaDataException(_loc.get(prefix + "-no-col-name",
                 context));
 
+        MappingRepository repos = (MappingRepository) context.getRepository();
+        DBDictionary dict = repos.getDBDictionary();
+
         // determine the column name based on given info, or template if none;
         // also make sure that if the user gave a column name, he didn't try
         // to put the column in an unexpected table
         if (colName == null)
             colName = tmplate.getName();
-        int dotIdx = colName.lastIndexOf('.');
+        int dotIdx = colName.lastIndexOf(dict.catalogSeparator);
         if (dotIdx == 0)
             colName = colName.substring(1);
         else if (dotIdx != -1) {
@@ -646,9 +650,6 @@
             throw new MetaDataException(_loc.get(prefix + "-bad-col-name",
                 context, colName, table));
 
-        MappingRepository repos = (MappingRepository) context.getRepository();
-        DBDictionary dict = repos.getDBDictionary();
-
         // use information from template column by default, allowing any
         // user-given specifics to override it
         int type = tmplate.getType();
@@ -1686,7 +1687,7 @@
         Column copy = new Column();
         if (col.getTable() != colTable || inverse)
             copy.setName(dict.getFullName(col.getTable(), true)
-                + "." + col.getName());
+                + dict.catalogSeparator + col.getName());
         else
             copy.setName(col.getName());
 
@@ -1699,7 +1700,7 @@
                 if ((!inverse && tcol.getTable() != targetTable)
                     || (inverse && tcol.getTable() != colTable))
                     copy.setTarget(dict.getFullName(tcol.getTable(), true)
-                        + "." + tcol.getName());
+                        + dict.catalogSeparator + tcol.getName());
                 else if (!defaultTarget(col, tcol, num))
                     copy.setTarget(tcol.getName());
             } else if (target instanceof Number)