openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jrba...@apache.org
Subject svn commit: r899784 [10/11] - in /openjpa/trunk: openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/conf/ openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/identifier/ openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/ openjpa-jdbc/src/main/ja...
Date Fri, 15 Jan 2010 19:38:26 GMT
Modified: openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/AnnotationPersistenceMappingParser.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/AnnotationPersistenceMappingParser.java?rev=899784&r1=899783&r2=899784&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/AnnotationPersistenceMappingParser.java (original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/AnnotationPersistenceMappingParser.java Fri Jan 15 19:38:18 2010
@@ -62,6 +62,9 @@
 
 import org.apache.commons.lang.StringUtils;
 import org.apache.openjpa.jdbc.conf.JDBCConfiguration;
+import org.apache.openjpa.jdbc.identifier.DBIdentifier;
+import org.apache.openjpa.jdbc.identifier.QualifiedDBIdentifier;
+import org.apache.openjpa.jdbc.identifier.DBIdentifier.DBIdentifierType;
 import org.apache.openjpa.jdbc.kernel.EagerFetchModes;
 import org.apache.openjpa.jdbc.meta.ClassMapping;
 import org.apache.openjpa.jdbc.meta.ClassMappingInfo;
@@ -113,8 +116,8 @@
     private static final Localizer _loc = Localizer.forPackage
         (AnnotationPersistenceMappingParser.class);
 
-    private static final Map<Class, MappingTag> _tags =
-        new HashMap<Class, MappingTag>();
+    private static final Map<Class<?>, MappingTag> _tags =
+        new HashMap<Class<?>, MappingTag>();
     
     private DBDictionary _dict; 
 
@@ -255,14 +258,9 @@
 
         meta = (SequenceMapping) getRepository().addSequenceMetaData(name);
         meta.setSequencePlugin(SequenceMapping.IMPL_VALUE_TABLE);
-        meta.setTable(toTableName(gen.schema(), gen.table(),
-            DBDictionary.DBIdentifiers.TABLE_GEN_SCHEMA, DBDictionary.DBIdentifiers.TABLE_GEN_TABLE));
-        String pkColumnName = _dict.delimitString(gen.pkColumnName(), 
-            DBDictionary.DBIdentifiers.TABLE_GEN_PK_COLUMN);
-        meta.setPrimaryKeyColumn(pkColumnName);
-        String valueColumnName = _dict.delimitString(gen.valueColumnName(), 
-            DBDictionary.DBIdentifiers.TABLE_GEN_VALUE_COLUMN);
-        meta.setSequenceColumn(valueColumnName);
+        meta.setTableIdentifier(toTableIdentifier(gen.schema(), gen.table()));
+        meta.setPrimaryKeyColumnIdentifier(DBIdentifier.newColumn(gen.pkColumnName(), delimit()));
+        meta.setSequenceColumnIdentifier(DBIdentifier.newColumn(gen.valueColumnName(),delimit()));
         meta.setPrimaryKeyValue(gen.pkColumnValue());
         meta.setInitialValue(gen.initialValue());
         meta.setAllocate(gen.allocationSize());
@@ -273,8 +271,10 @@
         case 0: 
         	break; // nothing to do
         case 1: 
-        	meta.setUniqueColumns(gen.uniqueConstraints()[0].columnNames());
-        	meta.setUniqueConstraintName(gen.uniqueConstraints()[0].name());
+        	meta.setUniqueColumnsIdentifier(DBIdentifier.toArray(gen.uniqueConstraints()[0].columnNames(), 
+        	    DBIdentifierType.COLUMN, delimit()));
+        	meta.setUniqueConstraintIdentifier(DBIdentifier.newConstraint(gen.uniqueConstraints()[0].name(), 
+        	    delimit()));
         	break;
         default:
         	log.warn(_loc.get("unique-many-on-seq-unsupported", el, name));
@@ -284,7 +284,7 @@
     @Override
     protected void parseClassMappingAnnotations(ClassMetaData meta) {
         ClassMapping cm = (ClassMapping) meta;
-        Class cls = cm.getDescribedType();
+        Class<?> cls = cm.getDescribedType();
 
         MappingTag tag;
         for (Annotation anno : cls.getDeclaredAnnotations()) {
@@ -486,13 +486,11 @@
         Column col = new Column();
         col.setFlag(Column.FLAG_PK_JOIN, true);
         if (!StringUtils.isEmpty(join.name()))
-            col.setName(_dict.delimitString(join.name(), DBDictionary.DBIdentifiers.PRIMARY_KEY_JOIN_COLUMN_NAME));
+            col.setIdentifier(DBIdentifier.newColumn(join.name(), delimit()));
         if (!StringUtils.isEmpty(join.columnDefinition()))
-            col.setTypeName(_dict.delimitString(join.columnDefinition(), 
-                DBDictionary.DBIdentifiers.PRIMARY_KEY_JOIN_COLUMN_COLUMN_DEFINITION));
+            col.setTypeIdentifier(DBIdentifier.newColumnDefinition(join.columnDefinition()));
         if (!StringUtils.isEmpty(join.referencedColumnName()))
-            col.setTarget(_dict.delimitString(join.referencedColumnName(),
-                DBDictionary.DBIdentifiers.PRIMARY_KEY_JOIN_COLUMN_REFERENCED_COLUMN_NAME));
+            col.setTargetIdentifier(DBIdentifier.newColumn(join.referencedColumnName(), delimit()));
         return col;
     }
 
@@ -502,30 +500,25 @@
     private void parseSecondaryTables(ClassMapping cm,
         SecondaryTable... tables) {
         ClassMappingInfo info = cm.getMappingInfo();
-        Log log = getLog();
 
-        String name;
-        String schema;
         List<Column> joins = null;
         for (SecondaryTable table : tables) {
-            name = _dict.delimitString(table.name(),
-                DBDictionary.DBIdentifiers.SECONDARY_TABLE_NAME) ;
-            if (StringUtils.isEmpty(name))
+            DBIdentifier sName = DBIdentifier.newTable(table.name(), delimit());
+            if (DBIdentifier.isEmpty(sName))
                 throw new MetaDataException(_loc.get("second-name", cm));
             if (!StringUtils.isEmpty(table.schema())) {
-                schema = _dict.delimitString(table.schema(),
-                    DBDictionary.DBIdentifiers.SECONDARY_TABLE_SCHEMA);
-                name = schema + "." + name;
+                DBIdentifier sSchema = DBIdentifier.newSchema(table.schema(), delimit());
+                sName = QualifiedDBIdentifier.newPath(sSchema, sName);
             }
             if (table.pkJoinColumns().length > 0) {
                 joins = new ArrayList<Column>(table.pkJoinColumns().length);
                 for (PrimaryKeyJoinColumn join : table.pkJoinColumns())
                     joins.add(newColumn(join));
-                info.setSecondaryTableJoinColumns(name, joins);
+                info.setSecondaryTableJoinColumns(sName, joins);
             } else {
-            	info.addSecondaryTable(name);
+            	info.addSecondaryTable(sName);
             }
-            addUniqueConstraints(name, cm, info, table.uniqueConstraints());
+            addUniqueConstraints(sName.getName(), cm, info, table.uniqueConstraints());
         }
     }
 
@@ -535,12 +528,11 @@
     private void parseTable(ClassMapping cm, Table table) {
         if (cm.isAbstract())
             throw new UserException(_loc.get("table-not-allowed", cm));
-        String tableName = toTableName(table.schema(), table.name(),
-            DBDictionary.DBIdentifiers.TABLE_SCHEMA, DBDictionary.DBIdentifiers.TABLE_NAME);
-        if (tableName != null) {
-            cm.getMappingInfo().setTableName(tableName);
+        DBIdentifier tName = toTableIdentifier(table.schema(), table.name());
+        if (!DBIdentifier.isNull(tName)) {
+            cm.getMappingInfo().setTableIdentifier(tName);
         }
-        addUniqueConstraints(tableName, cm, cm.getMappingInfo(),
+        addUniqueConstraints(tName.getName(), cm, cm.getMappingInfo(),
             table.uniqueConstraints());
     }
     
@@ -548,19 +540,18 @@
         String[] columnNames = anno.columnNames();
         if (columnNames == null || columnNames.length == 0)
             throw new UserException(_loc.get("unique-no-column", ctx));
-        _dict.delimitArray(columnNames, DBDictionary.DBIdentifiers.UNIQUE_CONSTRAINT_COLUMN_NAMES);
+        DBIdentifier[] sColNames = DBIdentifier.toArray(columnNames,DBIdentifierType.COLUMN, delimit());
         Unique uniqueConstraint = new Unique();
-        for (int i = 0; i < columnNames.length; i++) {
-            if (StringUtils.isEmpty(columnNames[i]))
+        for (int i = 0; i < sColNames.length; i++) {
+            if (DBIdentifier.isEmpty(sColNames[i]))
                 throw new UserException(_loc.get("unique-empty-column",
-                        Arrays.toString(columnNames), ctx));
+                        Arrays.toString(sColNames), ctx));
             Column column = new Column();
-            column.setName(columnNames[i]);
+            column.setIdentifier(sColNames[i]);
             uniqueConstraint.addColumn(column);
         }
-        String name = _dict.delimitString(anno.name(), DBDictionary.DBIdentifiers.UNIQUE_CONSTRAINT_NAME);
-        if (!StringUtils.isEmpty(name)) {
-            uniqueConstraint.setName(name);
+        if (!StringUtils.isEmpty(anno.name())) {
+            uniqueConstraint.setIdentifier(DBIdentifier.newConstraint(anno.name(), delimit()));
         }
         return uniqueConstraint;
     }
@@ -569,7 +560,7 @@
         MappingInfo info, UniqueConstraint... uniqueConstraints) {
         for (UniqueConstraint anno : uniqueConstraints) {
             Unique unique = createUniqueConstraint(ctx, anno);
-            unique.setTableName(table);
+            unique.setTableIdentifier(DBIdentifier.newTable(table, delimit()));
             if (info instanceof ClassMappingInfo)
                 ((ClassMappingInfo) info).addUnique(table, unique);
             else if (info instanceof FieldMappingInfo)
@@ -582,15 +573,16 @@
     /**
      * Form a qualified table name from a schema and table name.
      */
-    private String toTableName(String schema, String table, 
-        DBDictionary.DBIdentifiers schemaType, DBDictionary.DBIdentifiers nameType) {
-        if (StringUtils.isEmpty(table))
-            return null;
-        if (StringUtils.isEmpty(schema))
-            return _dict.delimitString(table, nameType);
-        String delimTable = _dict.delimitString(table, nameType);
-        String delimSchema = _dict.delimitString(schema, schemaType);
-        return delimSchema + "." + delimTable;
+    private DBIdentifier toTableIdentifier(String schema, String table) {
+        if (StringUtils.isEmpty(table)) {
+            return DBIdentifier.NULL;
+        }
+        DBIdentifier tName = DBIdentifier.newTable(table, delimit());
+        DBIdentifier sName = DBIdentifier.newSchema(schema, delimit());
+        if (DBIdentifier.isEmpty(tName) || DBIdentifier.isEmpty(sName)) {
+            return tName;
+        }
+        return QualifiedDBIdentifier.newPath(sName, tName);
     }
 
     /**
@@ -625,14 +617,13 @@
                         entity.discriminatorColumn());
 
                 for (FieldResult field : entity.fields()) {
-                    String column = _dict.delimitString(field.column(), 
-                        DBDictionary.DBIdentifiers.FIELD_RESULT_COLUMN);
-                    entityResult.addMapping(field.name(), column);
+                    DBIdentifier sColName = DBIdentifier.newColumn(field.column(), delimit());
+                    entityResult.addMapping(field.name(), sColName.getName());
                 }
             }
             for (ColumnResult column : anno.columns()) {
-                result.addColumnResult(_dict.delimitString(column.name(), 
-                    DBDictionary.DBIdentifiers.COLUMN_REUSLT_NAME));
+                DBIdentifier sName = DBIdentifier.newColumn(column.name(), delimit());
+                result.addColumnResult(sName.getName());
             }
         }
     }
@@ -643,11 +634,12 @@
     private void parseDiscriminatorColumn(ClassMapping cm,
         DiscriminatorColumn dcol) {
         Column col = new Column();
-        if (!StringUtils.isEmpty(dcol.name()))
-            col.setName(_dict.delimitString(dcol.name(), DBDictionary.DBIdentifiers.DISCRIMINATOR_COLUMN_NAME));
-        if (!StringUtils.isEmpty(dcol.columnDefinition()))
-            col.setTypeName(_dict.delimitString(dcol.columnDefinition(), 
-                DBDictionary.DBIdentifiers.DISCRIMINATOR_COLUMN_COLUMN_DEFINITION));
+        if (!StringUtils.isEmpty(dcol.name())) {
+            col.setIdentifier(DBIdentifier.newColumn(dcol.name(),delimit()));
+        }
+        if (!StringUtils.isEmpty(dcol.columnDefinition())) {
+            col.setTypeIdentifier(DBIdentifier.newColumnDefinition(dcol.columnDefinition()));
+        }
         Discriminator discrim = cm.getDiscriminator();
         switch (dcol.discriminatorType()) {
             case CHAR:
@@ -723,9 +715,9 @@
     private void parseDataStoreIdColumn(ClassMapping cm, DataStoreIdColumn id) {
         Column col = new Column();
         if (!StringUtils.isEmpty(id.name()))
-            col.setName(id.name());
+            col.setIdentifier(DBIdentifier.newColumn(id.name(), delimit()));
         if (!StringUtils.isEmpty(id.columnDefinition()))
-            col.setTypeName(id.columnDefinition());
+            col.setTypeIdentifier(DBIdentifier.newColumnDefinition(id.columnDefinition()));
         if (id.precision() != 0)
             col.setSize(id.precision());
         col.setFlag(Column.FLAG_UNINSERTABLE, !id.insertable());
@@ -760,7 +752,7 @@
         org.apache.openjpa.jdbc.schema.ForeignKey fk =
             new org.apache.openjpa.jdbc.schema.ForeignKey();
         if (!StringUtils.isEmpty(name))
-            fk.setName(name);
+            fk.setIdentifier(DBIdentifier.newForeignKey(name, delimit()));
         fk.setDeferred(deferred);
         fk.setDeleteAction(toForeignKeyAction(deleteAction));
         fk.setUpdateAction(toForeignKeyAction(updateAction));
@@ -820,7 +812,7 @@
         org.apache.openjpa.jdbc.schema.Index idx =
             new org.apache.openjpa.jdbc.schema.Index();
         if (!StringUtils.isEmpty(name))
-            idx.setName(name);
+            idx.setIdentifier(DBIdentifier.newConstraint(name, delimit()));
         idx.setUnique(unique);
         info.setIndex(idx);
     }
@@ -839,7 +831,7 @@
         org.apache.openjpa.jdbc.schema.Unique unq = 
             new org.apache.openjpa.jdbc.schema.Unique();
         if (!StringUtils.isEmpty(anno.name()))
-            unq.setName(anno.name());
+            unq.setIdentifier(DBIdentifier.newIndex(anno.name(), delimit()));
         unq.setDeferred(anno.deferred());
         info.setUnique(unq);
     }
@@ -853,18 +845,18 @@
 
         List<Column> cols = new ArrayList<Column>(vcols.length);
         for (VersionColumn vcol : vcols)
-            cols.add(newColumn(vcol));
+            cols.add(newColumn(vcol, delimit()));
         cm.getVersion().getMappingInfo().setColumns(cols);
     }
 
     /**
      * Create a new schema column with information from the given annotation.
      */
-    private static Column newColumn(VersionColumn anno) {
+    private static Column newColumn(VersionColumn anno, boolean delimit) {
         Column col = new Column();
-        col.setTableName(anno.table());
+        col.setTableIdentifier(DBIdentifier.newTable(anno.table(), delimit));
         if (!StringUtils.isEmpty(anno.name()))
-            col.setName(anno.name());
+            col.setIdentifier(DBIdentifier.newColumn(anno.name(), delimit));
         if (anno.precision() != 0)
             col.setSize(anno.precision());
         else if (anno.length() != 255)
@@ -872,8 +864,8 @@
         col.setNotNull(!anno.nullable());
         col.setDecimalDigits(anno.scale());
         if (!StringUtils.isEmpty(anno.columnDefinition())) {
-            col.setTypeName(anno.columnDefinition());
-            col.setType(Schemas.getJDBCType(col.getTypeName()));
+            col.setTypeIdentifier(DBIdentifier.newColumnDefinition(anno.columnDefinition()));
+            col.setType(Schemas.getJDBCType(col.getTypeIdentifier().getName()));
             col.setJavaType(JavaTypes.getTypeCode(Schemas.getJavaType
             	(col.getType(), col.getSize(), col.getDecimalDigits())));
         }
@@ -923,7 +915,7 @@
         List<Column> cols = new ArrayList<Column>(pcols.length);
         int unique = 0;
         for (int i = 0; i < pcols.length; i++) {
-            cols.add(newColumn(pcols[i]));
+            cols.add(newColumn(pcols[i], delimit()));
             unique |= (pcols[i].unique()) ? TRUE : FALSE;
         }
         setColumns(fm, fm.getElementMapping().getValueInfo(), cols, unique);
@@ -932,12 +924,12 @@
     /**
      * Create a new schema column with information from the given annotation.
      */
-    private static Column newColumn(ElementColumn anno) {
+    private static Column newColumn(ElementColumn anno, boolean delimit) {
         Column col = new Column();
         if (!StringUtils.isEmpty(anno.name()))
-            col.setName(anno.name());
+            col.setIdentifier(DBIdentifier.newColumn(anno.name(), delimit));
         if (!StringUtils.isEmpty(anno.columnDefinition()))
-            col.setTypeName(anno.columnDefinition());
+            col.setTypeIdentifier(DBIdentifier.newColumnDefinition(anno.columnDefinition()));
         if (anno.precision() != 0)
             col.setSize(anno.precision());
         else if (anno.length() != 255)
@@ -959,7 +951,7 @@
         List<Column> cols = new ArrayList<Column>(joins.length);
         int unique = 0;
         for (int i = 0; i < joins.length; i++) {
-            cols.add(newColumn(joins[i]));
+            cols.add(newColumn(joins[i], delimit()));
             unique |= (joins[i].unique()) ? TRUE : FALSE;
         }
         setColumns(fm, fm.getKeyMapping().getValueInfo(), cols, unique);
@@ -968,14 +960,14 @@
     /**
      *  Create a new schema column with information from the given annotation.
      */
-    private static Column newColumn(KeyJoinColumn join) {
+    private static Column newColumn(KeyJoinColumn join, boolean delimit) {
         Column col = new Column();
         if (!StringUtils.isEmpty(join.name()))
-            col.setName(join.name());
+            col.setIdentifier(DBIdentifier.newColumn(join.name(),delimit));
         if (!StringUtils.isEmpty(join.columnDefinition()))
-            col.setName(join.columnDefinition());
+            col.setIdentifier(DBIdentifier.newColumnDefinition(join.columnDefinition()));
         if (!StringUtils.isEmpty(join.referencedColumnName()))
-            col.setTarget(join.referencedColumnName());
+            col.setTargetIdentifier(DBIdentifier.newColumn(join.referencedColumnName(),delimit));
         if (!StringUtils.isEmpty(join.referencedAttributeName()))
             col.setTargetField(join.referencedAttributeName());
         col.setNotNull(!join.nullable());
@@ -1083,8 +1075,8 @@
                 case KEY_EMBEDDED_MAPPING:
                     KeyEmbeddedMapping kembed = (KeyEmbeddedMapping) anno;
                     parseEmbeddedMapping(fm.getKeyMapping(),
-                        kembed.nullIndicatorColumnName(),
-                        kembed.nullIndicatorAttributeName(),
+                        DBIdentifier.newColumn(kembed.nullIndicatorColumnName(), delimit()),
+                        DBIdentifier.newConstant(kembed.nullIndicatorAttributeName()),
                         kembed.overrides());
                     break;
                 case KEY_FK:
@@ -1169,8 +1161,8 @@
                 case ELEM_EMBEDDED_MAPPING:
                     ElementEmbeddedMapping ee = (ElementEmbeddedMapping) anno;
                     parseEmbeddedMapping(fm.getElementMapping(),
-                        ee.nullIndicatorAttributeName(),
-                        ee.nullIndicatorColumnName(),
+                        DBIdentifier.newConstant(ee.nullIndicatorAttributeName()),
+                        DBIdentifier.newColumn(ee.nullIndicatorColumnName(), delimit()),
                         ee.overrides());
                     break;
                 case ELEM_FK:
@@ -1228,8 +1220,8 @@
                     break;
                 case X_EMBEDDED_MAPPING:
                     XEmbeddedMapping embed = (XEmbeddedMapping) anno;
-                    parseEmbeddedMapping(fm, embed.nullIndicatorColumnName(),
-                        embed.nullIndicatorAttributeName(), embed.overrides());
+                    parseEmbeddedMapping(fm, DBIdentifier.newColumn(embed.nullIndicatorColumnName(), delimit()),
+                        DBIdentifier.newConstant(embed.nullIndicatorAttributeName()), embed.overrides());
                     break;
                 case X_JOIN_COL:
                     parseXJoinColumns(fm, fm.getValueInfo(), true,
@@ -1553,14 +1545,14 @@
         }
 
         int unique = 0;
-        String secondary = null;
+        DBIdentifier sSecondary = DBIdentifier.NULL;
         for (int i = 0; i < pcols.length; i++) {
             if (cols.size() > i)
-                setupColumn((Column) cols.get(i), pcols[i], _dict);
+                setupColumn((Column) cols.get(i), pcols[i], delimit());
             else {
                 if (cols.isEmpty())
                     cols = new ArrayList<Column>(pcols.length);
-                cols.add(newColumn(pcols[i], _dict));
+                cols.add(newColumn(pcols[i], delimit()));
             }
             
             if (xmlTypeClass != null
@@ -1572,30 +1564,29 @@
                     .getDBDictionary();
                 if (dict.supportsXMLColumn)
                     // column maps to xml type
-                    ((Column) cols.get(i)).setTypeName(dict.xmlTypeName);
+                    ((Column) cols.get(i)).setTypeIdentifier(DBIdentifier.newColumnDefinition(dict.xmlTypeName));
             }
 
             unique |= (pcols[i].unique()) ? TRUE : FALSE;
-            String secTable = _dict.delimitString(pcols[i].table(),
-                DBDictionary.DBIdentifiers.SECONDARY_TABLE_NAME);
-        	secondary = trackSecondaryTable(fm, secondary,	secTable, i);
+            DBIdentifier sSecTable = DBIdentifier.newTable(pcols[i].table(), delimit());
+        	sSecondary = trackSecondaryTable(fm, sSecondary, sSecTable, i);
         }
 
         if (fm.isElementCollection())
             setColumns(fm, fm.getElementMapping().getValueInfo(), cols, unique);
         else
             setColumns(fm, fm.getValueInfo(), cols, unique);
-        if (secondary != null)
-            fm.getMappingInfo().setTableName(secondary);
+        if (!DBIdentifier.isNull(sSecondary))
+            fm.getMappingInfo().setTableIdentifier(sSecondary);
     }
 
     /**
      * Create a new schema column with information from the given annotation.
      */
     private static Column newColumn(javax.persistence.Column anno,
-        DBDictionary dict) {
+        boolean delimit) {
         Column col = new Column();
-        setupColumn(col, anno, dict);
+        setupColumn(col, anno, delimit);
         return col;
     }
 
@@ -1603,13 +1594,11 @@
      * Setup the given column with information from the given annotation.
      */
     private static void setupColumn(Column col, javax.persistence.Column anno,
-        DBDictionary dict) {
+        boolean delimit) {
         if (!StringUtils.isEmpty(anno.name()))
-            col.setName(dict.delimitString(anno.name(),
-                DBDictionary.DBIdentifiers.COLUMN_NAME));
+            col.setIdentifier(DBIdentifier.newColumn(anno.name(),delimit));
         if (!StringUtils.isEmpty(anno.columnDefinition()))
-            col.setTypeName(dict.delimitString(anno.columnDefinition(),
-                DBDictionary.DBIdentifiers.COLUMN_COLUMN_DEFINITION));
+            col.setTypeIdentifier(DBIdentifier.newColumnDefinition(anno.columnDefinition()));
         if (anno.precision() != 0)
             col.setSize(anno.precision());
         else if (anno.length() != 255)
@@ -1645,13 +1634,13 @@
      * @param colSecondary secondary table for current column
      * @return secondary table for field
      */
-    private String trackSecondaryTable(FieldMapping fm, String secondary,
-        String colSecondary, int col) {
-        if (StringUtils.isEmpty(colSecondary))
-            colSecondary = null;
+    private DBIdentifier trackSecondaryTable(FieldMapping fm, DBIdentifier secondary,
+        DBIdentifier colSecondary, int col) {
+        if (DBIdentifier.isEmpty(colSecondary))
+            colSecondary = DBIdentifier.NULL;
         if (col == 0)
             return colSecondary;
-        if (!StringUtils.equalsIgnoreCase(secondary, colSecondary))
+        if (!DBIdentifier.equalsIgnoreCase(secondary, colSecondary))
             throw new MetaDataException(_loc.get("second-inconsist", fm));
         return secondary;
     }
@@ -1661,12 +1650,12 @@
      */
     private void parseJoinTable(FieldMapping fm, JoinTable join) {
     	FieldMappingInfo info = fm.getMappingInfo();
-        info.setTableName(toTableName(join.schema(), join.name(),
-            DBDictionary.DBIdentifiers.JOIN_TABLE_SCHEMA, DBDictionary.DBIdentifiers.JOIN_TABLE_NAME));
+    	DBIdentifier joinTbl = toTableIdentifier(join.schema(), join.name());
+        info.setTableIdentifier(joinTbl);
         parseJoinColumns(fm, info, false, join.joinColumns());
         parseJoinColumns(fm, fm.getElementMapping().getValueInfo(), false,
             join.inverseJoinColumns());
-        addUniqueConstraints(info.getTableName(), fm, info,  
+        addUniqueConstraints(info.getTableIdentifier().getName(), fm, info,  
             join.uniqueConstraints());
     }
 
@@ -1680,20 +1669,20 @@
 
         List<Column> cols = new ArrayList<Column>(joins.length);
         int unique = 0;
-        String secondary = null;
+        DBIdentifier sSecondary = DBIdentifier.NULL;
         for (int i = 0; i < joins.length; i++) {
             cols.add(newColumn(joins[i]));
             unique |= (joins[i].unique()) ? TRUE : FALSE;
-            String table = _dict.delimitString(joins[i].table(), DBDictionary.DBIdentifiers.JOIN_COLUMN_TABLE);
-            secondary = trackSecondaryTable(fm, secondary,
-                table, i);
-            if (!secondaryAllowed && secondary != null)
+            DBIdentifier sTable = DBIdentifier.newTable(joins[i].table(), delimit());
+            sSecondary = trackSecondaryTable(fm, sSecondary,
+                sTable, i);
+            if (!secondaryAllowed && !DBIdentifier.isNull(sSecondary))
                 throw new MetaDataException(_loc.get("bad-second", fm));
         }
 
         setColumns(fm, info, cols, unique);
-        if (secondary != null)
-            fm.getMappingInfo().setTableName(secondary);
+        if (!DBIdentifier.isNull(sSecondary))
+            fm.getMappingInfo().setTableIdentifier(sSecondary);
         String mappedByIdValue = fm.getMappedByIdValue();
         if (mappedByIdValue != null) {
             FieldMapping[] pks = fm.getDefiningMapping().getPrimaryKeyFieldMappings();
@@ -1717,13 +1706,11 @@
     private Column newColumn(JoinColumn join) {
         Column col = new Column();
         if (!StringUtils.isEmpty(join.name()))
-            col.setName(_dict.delimitString(join.name(), DBDictionary.DBIdentifiers.JOIN_COLUMN_NAME));
+            col.setIdentifier(DBIdentifier.newColumn(join.name(), delimit()));
         if (!StringUtils.isEmpty(join.columnDefinition()))
-            col.setTypeName(_dict.delimitString(join.columnDefinition(), 
-                DBDictionary.DBIdentifiers.JOIN_COLUMN_COLUMN_DEFINITION));
+            col.setTypeIdentifier(DBIdentifier.newColumnDefinition(join.columnDefinition())); 
         if (!StringUtils.isEmpty(join.referencedColumnName()))
-            col.setTarget(_dict.delimitString(join.referencedColumnName(), 
-                DBDictionary.DBIdentifiers.JOIN_COLUMN_REFERENCED_COLUMN_NAME));
+            col.setTargetIdentifier(DBIdentifier.newColumn(join.referencedColumnName(), delimit()));
         col.setNotNull(!join.nullable());
         col.setFlag(Column.FLAG_UNINSERTABLE, !join.insertable());
         col.setFlag(Column.FLAG_UNUPDATABLE, !join.updatable());
@@ -1740,7 +1727,7 @@
         List<Column> cols = new ArrayList<Column>(pcols.length);
         int unique = 0;
         for (int i = 0; i < pcols.length; i++) {
-            cols.add(newColumn(pcols[i]));
+            cols.add(newColumn(pcols[i], delimit()));
             unique |= (pcols[i].unique()) ? TRUE : FALSE;
         }
         setColumns(fm, fm.getKeyMapping().getValueInfo(), cols, unique);
@@ -1749,12 +1736,12 @@
     /**
      * Create a new schema column with information from the given annotation.
      */
-    private static Column newColumn(KeyColumn anno) {
+    private static Column newColumn(KeyColumn anno, boolean delimit) {
         Column col = new Column();
         if (!StringUtils.isEmpty(anno.name()))
-            col.setName(anno.name());
+            col.setIdentifier(DBIdentifier.newColumn(anno.name(), delimit));
         if (!StringUtils.isEmpty(anno.columnDefinition()))
-            col.setTypeName(anno.columnDefinition());
+            col.setTypeIdentifier(DBIdentifier.newColumnDefinition(anno.columnDefinition()));
         if (anno.precision() != 0)
             col.setSize(anno.precision());
         else if (anno.length() != 255)
@@ -1787,32 +1774,32 @@
 
         List<Column> cols = new ArrayList<Column>(joins.length);
         int unique = 0;
-        String secondary = null;
+        DBIdentifier sSecondary = DBIdentifier.NULL;
         for (int i = 0; i < joins.length; i++) {
-            cols.add(newColumn(joins[i]));
+            cols.add(newColumn(joins[i], delimit()));
             unique |= (joins[i].unique()) ? TRUE : FALSE;
-            secondary = trackSecondaryTable(fm, secondary,
-                joins[i].table(), i);
-            if (!secondaryAllowed && secondary != null)
+            sSecondary = trackSecondaryTable(fm, sSecondary,
+                DBIdentifier.newTable(joins[i].table(), delimit()), i);
+            if (!secondaryAllowed && !DBIdentifier.isNull(sSecondary))
                 throw new MetaDataException(_loc.get("bad-second", fm));
         }
 
         setColumns(fm, info, cols, unique);
-        if (secondary != null)
-            fm.getMappingInfo().setTableName(secondary);
+        if (!DBIdentifier.isNull(sSecondary))
+            fm.getMappingInfo().setTableIdentifier(sSecondary);
     }
 
     /**
      * Create a new schema column with information from the given annotation.
      */
-    private static Column newColumn(XJoinColumn join) {
+    private static Column newColumn(XJoinColumn join, boolean delimit) {
         Column col = new Column();
         if (!StringUtils.isEmpty(join.name()))
-            col.setName(join.name());
+            col.setIdentifier(DBIdentifier.newColumn(join.name(), delimit));
         if (!StringUtils.isEmpty(join.columnDefinition()))
-            col.setTypeName(join.columnDefinition());
+            col.setTypeIdentifier(DBIdentifier.newColumnDefinition(join.columnDefinition()));
         if (!StringUtils.isEmpty(join.referencedColumnName()))
-            col.setTarget(join.referencedColumnName());
+            col.setTargetIdentifier(DBIdentifier.newColumn(join.referencedColumnName(), delimit));
         if (!StringUtils.isEmpty(join.referencedAttributeName()))
             col.setTargetField(join.referencedAttributeName());
         col.setNotNull(!join.nullable());
@@ -1838,12 +1825,12 @@
             populate(efm, over);
         }
 
-        String nullInd = null;
+        DBIdentifier nullInd = DBIdentifier.NULL;
         if (!StringUtils.isEmpty(anno.nullIndicatorAttributeName()))
-            nullInd = anno.nullIndicatorAttributeName();
+            nullInd = DBIdentifier.newConstant(anno.nullIndicatorAttributeName());
         else if (!StringUtils.isEmpty(anno.nullIndicatorColumnName()))
-            nullInd = anno.nullIndicatorColumnName();
-        if (nullInd == null)
+            nullInd = DBIdentifier.newColumn(anno.nullIndicatorColumnName(), delimit());
+        if (DBIdentifier.isNull(nullInd))
             return;
 
         ValueMappingInfo info = fm.getValueInfo();
@@ -1854,7 +1841,7 @@
      * Parse embedded info for the given mapping.
      */
     private void parseEmbeddedMapping(ValueMapping vm, 
-        String nullIndicatorAttribute, String nullIndicatorColumn,
+        DBIdentifier nullIndicatorAttribute, DBIdentifier nullIndicatorColumn,
         XMappingOverride[] overrides) {
         ClassMapping embed = vm.getEmbeddedMapping();
         if (embed == null)
@@ -1869,25 +1856,25 @@
             populate(efm, over);
         }
 
-        String nullInd = null;
-        if (!StringUtils.isEmpty(nullIndicatorAttribute))
+        DBIdentifier nullInd = DBIdentifier.NULL;
+        if (!DBIdentifier.isEmpty(nullIndicatorAttribute))
             nullInd = nullIndicatorAttribute;
-        else if (!StringUtils.isEmpty(nullIndicatorColumn))
+        else if (!DBIdentifier.isEmpty(nullIndicatorColumn))
             nullInd = nullIndicatorColumn;
-        if (nullInd == null)
+        if (DBIdentifier.isNull(nullInd))
             return;
 
         ValueMappingInfo info = vm.getValueInfo();
         populateNullIndicator(nullInd, info);
     }
 
-    private void populateNullIndicator(String nullInd, ValueMappingInfo info) {
-        if ("false".equals(nullInd))
+    private void populateNullIndicator(DBIdentifier nullInd, ValueMappingInfo info) {
+        if ("false".equals(nullInd.getName()))
             info.setCanIndicateNull(false);
         else {
             Column col = new Column();
-            if (!"true".equals(nullInd))
-                col.setName(nullInd);
+            if (!"true".equals(nullInd.getName()))
+                col.setIdentifier(nullInd);
             info.setColumns(Arrays.asList(new Column[]{ col }));
         }
     }
@@ -1896,8 +1883,8 @@
      * Parse @ContainerTable.
      */
     protected void parseContainerTable(FieldMapping fm, ContainerTable ctbl) {
-        fm.getMappingInfo().setTableName(toTableName(ctbl.schema(),
-            ctbl.name(), null, null));
+        DBIdentifier tblName = toTableIdentifier(ctbl.schema(), ctbl.name());
+        fm.getMappingInfo().setTableIdentifier(tblName);
         parseXJoinColumns(fm, fm.getMappingInfo(), false, ctbl.joinColumns());
         if (ctbl.joinForeignKey().specified())
             parseForeignKey(fm.getMappingInfo(), ctbl.joinForeignKey());
@@ -1910,11 +1897,11 @@
      */
     protected void parseCollectionTable(FieldMapping fm, CollectionTable ctbl) {
         FieldMappingInfo info = fm.getMappingInfo(); 
-        info.setTableName(toTableName(ctbl.schema(), ctbl.name(),
-            DBDictionary.DBIdentifiers.COLLECTION_TABLE_SCHEMA, DBDictionary.DBIdentifiers.COLLECTION_TABLE_NAME));
+        DBIdentifier tblName = toTableIdentifier(ctbl.schema(), ctbl.name());
+        info.setTableIdentifier(tblName);
         //ctbl.catalog()
         parseJoinColumns(fm, fm.getMappingInfo(), false, ctbl.joinColumns());
-        addUniqueConstraints(info.getTableName(), fm.getDefiningMetaData(), 
+        addUniqueConstraints(info.getTableIdentifier().getName(), fm.getDefiningMetaData(), 
             info, ctbl.uniqueConstraints());
     }
     
@@ -1929,10 +1916,9 @@
 
         Column col = new Column();
         if (!StringUtils.isEmpty(order.name()))
-            col.setName(_dict.delimitString(order.name(), DBDictionary.DBIdentifiers.ORDER_COLUMN_NAME));
+            col.setIdentifier(DBIdentifier.newColumn(order.name(), delimit()));
         if (!StringUtils.isEmpty(order.columnDefinition()))
-            col.setTypeName(_dict.delimitString(order.columnDefinition(), 
-                DBDictionary.DBIdentifiers.ORDER_COLUMN_COLUMN_DEFINITION));
+            col.setTypeIdentifier(DBIdentifier.newColumnDefinition(order.columnDefinition())); 
         if (order.precision() != 0)
             col.setSize(order.precision());
         col.setFlag(Column.FLAG_UNINSERTABLE, !order.insertable());
@@ -1948,10 +1934,9 @@
         
         Column col = new Column();
         if (!StringUtils.isEmpty(order.name()))
-            col.setName(_dict.delimitString(order.name(), DBDictionary.DBIdentifiers.ORDER_COLUMN_NAME));
+            col.setIdentifier(DBIdentifier.newColumn(order.name(), delimit()));
         if (!StringUtils.isEmpty(order.columnDefinition()))
-            col.setTypeName(_dict.delimitString(order.columnDefinition(), 
-                DBDictionary.DBIdentifiers.ORDER_COLUMN_COLUMN_DEFINITION));
+            col.setTypeIdentifier(DBIdentifier.newColumnDefinition(order.columnDefinition()));
         col.setNotNull(!order.nullable());
         col.setFlag(Column.FLAG_UNINSERTABLE, !order.insertable());
         col.setFlag(Column.FLAG_UNUPDATABLE, !order.updatable());
@@ -1970,7 +1955,7 @@
         List<Column> cols = new ArrayList<Column>(joins.length);
         int unique = 0;
         for (int i = 0; i < joins.length; i++) {
-            cols.add(newColumn(joins[i]));
+            cols.add(newColumn(joins[i], delimit()));
             unique |= (joins[i].unique()) ? TRUE : FALSE;
         }
         setColumns(fm, fm.getElementMapping().getValueInfo(), cols, unique);
@@ -1979,14 +1964,14 @@
     /**
      * Create a new schema column with information from the given annotation.
      */
-    private static Column newColumn(ElementJoinColumn join) {
+    private static Column newColumn(ElementJoinColumn join, boolean delimit) {
         Column col = new Column();
         if (!StringUtils.isEmpty(join.name()))
-            col.setName(join.name());
+            col.setIdentifier(DBIdentifier.newColumn(join.name(), delimit));
         if (!StringUtils.isEmpty(join.columnDefinition()))
-            col.setTypeName(join.columnDefinition());
+            col.setTypeIdentifier(DBIdentifier.newColumnDefinition(join.columnDefinition()));
         if (!StringUtils.isEmpty(join.referencedColumnName()))
-            col.setTarget(join.referencedColumnName());
+            col.setTargetIdentifier(DBIdentifier.newColumn(join.referencedColumnName(), delimit));
         if (!StringUtils.isEmpty(join.referencedAttributeName()))
             col.setTargetField(join.referencedAttributeName());
         col.setNotNull(!join.nullable());
@@ -2002,8 +1987,7 @@
         int unique = 0;
         FieldMappingInfo info = fm.getMappingInfo();
         if (anno.table() != null && anno.table().length() > 0) {
-            String tableName = _dict.delimitString(anno.table(), DBDictionary.DBIdentifiers.MAP_KEY_COLUMN_TABLE);
-            info.setTableName(tableName);
+            info.setTableIdentifier(DBIdentifier.newTable(anno.table(), delimit()));
         }
         Column col = new Column();
         setupMapKeyColumn(fm, col, anno);
@@ -2017,14 +2001,12 @@
     private void setupMapKeyColumn(FieldMapping fm, Column col, 
         MapKeyColumn anno) {
         if (!StringUtils.isEmpty(anno.name())) {
-            String name = _dict.delimitString(anno.name(), DBDictionary.DBIdentifiers.MAP_KEY_COLUMN_NAME);
-            col.setName(name);
+            col.setIdentifier(DBIdentifier.newColumn(anno.name(), delimit()));
         }
         else 
-            col.setName(fm.getName() + "_" + "KEY");
+            col.setIdentifier(DBIdentifier.newColumn(fm.getName() + "_" + "KEY", delimit()));
         if (!StringUtils.isEmpty(anno.columnDefinition()))
-            col.setTypeName(_dict.delimitString(anno.columnDefinition(), 
-                DBDictionary.DBIdentifiers.MAP_KEY_COLUMN_COLUMN_DEFINITION));
+            col.setTypeIdentifier(DBIdentifier.newColumnDefinition(anno.columnDefinition()));
         if (anno.precision() != 0)
             col.setSize(anno.precision());
         else if (anno.length() != 255)
@@ -2073,29 +2055,42 @@
     private Column newColumn(MapKeyJoinColumn join) {
         Column col = new Column();
         if (!StringUtils.isEmpty(join.name()))
-            col.setName(_dict.delimitString(join.name(), DBDictionary.DBIdentifiers.MAP_KEY_JOIN_COLUMN_NAME));
+            col.setIdentifier(DBIdentifier.newColumn(join.name(), delimit()));
         if (!StringUtils.isEmpty(join.columnDefinition()))
-            col.setTypeName(_dict.delimitString(join.columnDefinition(), 
-                DBDictionary.DBIdentifiers.MAP_KEY_JOIN_COLUMN_COLUMN_DEFINITION));
+            col.setTypeIdentifier(DBIdentifier.newColumnDefinition(join.columnDefinition())); 
         if (!StringUtils.isEmpty(join.referencedColumnName()))
-            col.setTarget(_dict.delimitString(join.referencedColumnName(), 
-                DBDictionary.DBIdentifiers.MAP_KEY_JOIN_COLUMN_REFERENCED_COLUMN_NAME));
+            col.setTargetIdentifier(DBIdentifier.newColumn(join.referencedColumnName(), delimit())); 
         col.setNotNull(!join.nullable());
         col.setFlag(Column.FLAG_UNINSERTABLE, !join.insertable());
         col.setFlag(Column.FLAG_UNUPDATABLE, !join.updatable ());
         return col;
     }
+
+    @Override
+    protected String normalizeSequenceName(String seqName) {
+        if (StringUtils.isEmpty(seqName)) {
+            return seqName;
+        }
+        return DBIdentifier.newSequence(seqName, delimit()).getName();
+    }
     
     @Override
-    protected String delimitString(String name, DBIdentifiers type) {
-        if (type == DBIdentifiers.SEQUENCE_GEN_SCHEMA) {
-            return _dict.delimitString(name, DBDictionary.DBIdentifiers.SEQUENCE_GEN_SCHEMA);
+    protected String normalizeSchemaName(String schName) {
+        if (StringUtils.isEmpty(schName)) {
+            return schName;
         }
-        else if (type == DBIdentifiers.SEQUENCE_GEN_SEQ_NAME) {
-            return _dict.delimitString(name, DBDictionary.DBIdentifiers.SEQUENCE_GEN_SEQ_NAME);
+        return DBIdentifier.newSchema(schName, delimit()).getName();
+    }
+
+    @Override
+    protected String normalizeCatalogName(String catName) {
+        if (StringUtils.isEmpty(catName)) {
+            return catName;
         }
-        
-        return name;
+        return DBIdentifier.newCatalog(catName, delimit()).getName();
+    }
+
+    private boolean delimit() {
+        return _dict.getDelimitIdentifiers();
     }
-    
 }

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/MappingTag.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/MappingTag.java?rev=899784&r1=899783&r2=899784&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/MappingTag.java (original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/MappingTag.java Fri Jan 15 19:38:18 2010
@@ -39,6 +39,7 @@
     COLLECTION_TABLE,
     COLUMN_NAME,
     COLUMN_RESULT,
+    DELIMITED_IDS,
     DISCRIM_COL,
     DISCRIM_VAL,
     ENTITY_RESULT,

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/PersistenceMappingDefaults.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/PersistenceMappingDefaults.java?rev=899784&r1=899783&r2=899784&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/PersistenceMappingDefaults.java (original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/PersistenceMappingDefaults.java Fri Jan 15 19:38:18 2010
@@ -18,6 +18,8 @@
  */
 package org.apache.openjpa.persistence.jdbc;
 
+import org.apache.openjpa.jdbc.identifier.Normalizer;
+import org.apache.openjpa.jdbc.identifier.DBIdentifier;
 import org.apache.openjpa.jdbc.meta.ClassMapping;
 import org.apache.openjpa.jdbc.meta.Discriminator;
 import org.apache.openjpa.jdbc.meta.FieldMapping;
@@ -131,15 +133,20 @@
 
     @Override
     public String getTableName(FieldMapping fm, Schema schema) {
+        return getTableIdentifier(fm, schema).getName();
+    }
+
+    @Override
+    public DBIdentifier getTableIdentifier(FieldMapping fm, Schema schema) {
         // base name is table of defining type + '_'
         ClassMapping clm = fm.getDefiningMapping();
         Table table = getTable(clm);
         
-        String name = null;
+        DBIdentifier sName = DBIdentifier.NULL;
         if (fm.isElementCollection()) 
-            name = clm.getTypeAlias();
+            sName = DBIdentifier.newTable(clm.getTypeAlias());
         else 
-            name = table.getName();
+            sName = table.getIdentifier();
         
         // if this is an assocation table, spec says to suffix with table of
         // the related type. spec doesn't cover other cases; we're going to
@@ -147,17 +154,17 @@
         ClassMapping rel = fm.getElementMapping().getTypeMapping();
         boolean assoc = rel != null && rel.getTable() != null
             && fm.getTypeCode() != JavaTypes.MAP;
-        String name2 = null;
+        DBIdentifier sName2 = DBIdentifier.NULL;
         if (assoc) {
-            name2 = rel.getTable().getName();
+            sName2 = rel.getTable().getIdentifier();
         }
         else {
-            name2 = fm.getName();
+            sName2 = DBIdentifier.newTable(fm.getName().replace('$', '_'));
         }
         
-        name = dict.combineNames(name, name2);
+        sName = DBIdentifier.combine(sName, sName2.getName());
         
-        return name.replace('$', '_');
+        return sName;
     }
     
     private Table getTable(ClassMapping clm) {
@@ -184,28 +191,35 @@
         // if this is a bidi relation, prefix with inverse field name, else
         // prefix with owning entity name
         FieldMapping[] inverses = fm.getInverseMappings();
-        String name;
+        DBIdentifier sName = DBIdentifier.NULL;
         if (inverses.length > 0)
-            name = inverses[0].getName();
+            sName = DBIdentifier.newColumn(inverses[0].getName());
         else
-            name = fm.getDefiningMapping().getTypeAlias();
-        String targetName = ((Column) target).getName();
-        String tempName = null;
-        if ((name.length() + targetName.length()) >= dict.maxColumnNameLength)
-            tempName = name.substring(0, dict.maxColumnNameLength
+            sName = DBIdentifier.newColumn(fm.getDefiningMapping().getTypeAlias());
+        DBIdentifier targetName = ((Column) target).getIdentifier();
+        DBIdentifier tempName = DBIdentifier.NULL;
+        if ((sName.length() + targetName.length()) >= dict.maxColumnNameLength)
+            tempName = DBIdentifier.truncate(sName, dict.maxColumnNameLength
                     - targetName.length() - 1);
         // suffix with '_' + target column
-        if (tempName == null)
-            tempName = name;
-        name = dict.combineNames(tempName, targetName);
-        name = dict.getValidColumnName(name, foreign);
-        col.setName(name);
+        if (DBIdentifier.isNull(tempName))
+            tempName = sName;
+        sName = DBIdentifier.combine(tempName, targetName.getName());
+        sName = dict.getValidColumnName(sName, foreign);
+        col.setIdentifier(sName);
     }
 
     @Override
     public void populateForeignKeyColumn(ValueMapping vm, String name,
         Table local, Table foreign, Column col, Object target, boolean inverse,
         int pos, int cols) {
+         populateForeignKeyColumn(vm, DBIdentifier.newColumn(name), local,
+            foreign, col, target, inverse, pos, cols);
+    }
+
+    public void populateForeignKeyColumn(ValueMapping vm, DBIdentifier sName,
+        Table local, Table foreign, Column col, Object target, boolean inverse,
+        int pos, int cols) {
         boolean elem = vm == vm.getFieldMapping().getElement()
             && vm.getFieldMapping().getTypeCode() != JavaTypes.MAP;
 
@@ -218,19 +232,19 @@
         // otherwise jpa always uses <field>_<pkcol> for column name, even
         // when only one col
         if (target instanceof Column) {
-            if (name == null) {
-                name = col.getName();
+            if (DBIdentifier.isNull(sName)) {
+                sName = col.getIdentifier();
             } else {
                 if (elem)
-                    name = vm.getFieldMapping().getName();
+                    sName = DBIdentifier.newColumn(vm.getFieldMapping().getName());
                 if (isRemoveHungarianNotation())
-                    name = removeHungarianNotation(name);
-                name = dict.combineNames(name, ((Column)target).getName());
+                    sName = DBIdentifier.newColumn(Normalizer.removeHungarianNotation(sName.getName()));
+                sName = sName.combine(sName, ((Column)target).getIdentifier().getName());
 
                 // No need to check for uniqueness.
-                name = dict.getValidColumnName(name, local, false);
+                sName = dict.getValidColumnName(sName, local, false);
             }
-            col.setName(name);
+            col.setIdentifier(sName);
         }
     }
 
@@ -239,7 +253,7 @@
         // check for version field and use its name as column name
         FieldMapping fm = vers.getClassMapping().getVersionFieldMapping();
         if (fm != null && cols.length == 1)
-            cols[0].setName(fm.getName());
+            cols[0].setIdentifier(DBIdentifier.newColumn(fm.getName()));
         else
             super.populateColumns(vers, table, cols);
     }

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/XMLPersistenceMappingParser.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/XMLPersistenceMappingParser.java?rev=899784&r1=899783&r2=899784&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/XMLPersistenceMappingParser.java (original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/XMLPersistenceMappingParser.java Fri Jan 15 19:38:18 2010
@@ -33,6 +33,8 @@
 
 import org.apache.commons.lang.StringUtils;
 import org.apache.openjpa.jdbc.conf.JDBCConfiguration;
+import org.apache.openjpa.jdbc.identifier.DBIdentifier;
+import org.apache.openjpa.jdbc.identifier.QualifiedDBIdentifier;
 import org.apache.openjpa.jdbc.meta.ClassMapping;
 import org.apache.openjpa.jdbc.meta.ClassMappingInfo;
 import org.apache.openjpa.jdbc.meta.DiscriminatorMappingInfo;
@@ -42,26 +44,23 @@
 import org.apache.openjpa.jdbc.meta.MappingRepository;
 import org.apache.openjpa.jdbc.meta.QueryResultMapping;
 import org.apache.openjpa.jdbc.meta.SequenceMapping;
-import org.apache.openjpa.jdbc.meta.ValueMapping;
+import org.apache.openjpa.jdbc.meta.QueryResultMapping.PCResult;
 import org.apache.openjpa.jdbc.meta.strats.EnumValueHandler;
 import org.apache.openjpa.jdbc.meta.strats.FlatClassStrategy;
 import org.apache.openjpa.jdbc.meta.strats.FullClassStrategy;
 import org.apache.openjpa.jdbc.meta.strats.NoneClassStrategy;
 import org.apache.openjpa.jdbc.meta.strats.VerticalClassStrategy;
 import org.apache.openjpa.jdbc.schema.Column;
-import org.apache.openjpa.jdbc.schema.Table;
 import org.apache.openjpa.jdbc.schema.Unique;
 import org.apache.openjpa.jdbc.sql.DBDictionary;
 import org.apache.openjpa.lib.log.Log;
+import org.apache.openjpa.lib.meta.SourceTracker;
 import org.apache.openjpa.lib.util.Localizer;
 import org.apache.openjpa.meta.ClassMetaData;
 import org.apache.openjpa.meta.FieldMetaData;
 import org.apache.openjpa.meta.JavaTypes;
-import org.apache.openjpa.meta.MetaDataContext;
-import org.apache.openjpa.meta.ValueMetaData;
 import org.apache.openjpa.persistence.XMLPersistenceMetaDataParser;
 import org.apache.openjpa.util.InternalException;
-import org.apache.openjpa.util.MetaDataException;
 import org.apache.openjpa.util.UserException;
 import org.xml.sax.Attributes;
 import org.xml.sax.Locator;
@@ -88,6 +87,7 @@
         _elems.put("column", COL);
         _elems.put("column-name", COLUMN_NAME);
         _elems.put("column-result", COLUMN_RESULT);
+        _elems.put("delimited-identifiers", DELIMITED_IDS);
         _elems.put("discriminator-column", DISCRIM_COL);
         _elems.put("discriminator-value", DISCRIM_VAL);
         _elems.put("entity-result", ENTITY_RESULT);
@@ -128,6 +128,7 @@
     private DiscriminatorType _discType;
     private Column _discCol;
     private int _resultIdx = 0;
+    private final DBDictionary _dict;
 
     private final Map<Class<?>, ArrayList<DeferredEmbeddableOverrides>> 
         _deferredMappings = new HashMap<Class<?>, 
@@ -138,6 +139,7 @@
      */
     public XMLPersistenceMappingParser(JDBCConfiguration conf) {
         super(conf);
+        _dict = conf.getDBDictionaryInstance();
     }
 
     @Override
@@ -297,7 +299,7 @@
             Object current = currentElement();
             if (current instanceof Unique) {
                 Unique unq = (Unique)current;
-                unq.setName(name);
+                unq.setIdentifier(DBIdentifier.newConstraint(name, delimit()));
             }
         }
             
@@ -372,7 +374,7 @@
         throws SAXException {
         ClassMapping cm = (ClassMapping) meta;
         if (_schema != null)
-            cm.getMappingInfo().setSchemaName(_schema);
+            cm.getMappingInfo().setSchemaIdentifier(DBIdentifier.newSchema(_schema, delimit()));
 
         if (_supJoinCols != null)
             cm.getMappingInfo().setColumns(_supJoinCols);
@@ -413,10 +415,10 @@
      */
     private boolean startSecondaryTable(Attributes attrs)
         throws SAXException {
-        _secondaryTable = toTableName(attrs.getValue("schema"),
-            attrs.getValue("name"));
+        _secondaryTable = toTableIdentifier(attrs.getValue("schema"),
+            attrs.getValue("name")).getName();
         ((ClassMapping)currentElement()).getMappingInfo()
-        	.addSecondaryTable(_secondaryTable);
+        	.addSecondaryTable(DBIdentifier.newTable(_secondaryTable));
         return true;
     }
 
@@ -426,7 +428,7 @@
     private void endSecondaryTable() {
         ClassMapping cm = (ClassMapping) currentElement();
         ClassMappingInfo info = cm.getMappingInfo();
-        info.setSecondaryTableJoinColumns(_secondaryTable, _joinCols);
+        info.setSecondaryTableJoinColumns(DBIdentifier.newTable(_secondaryTable, delimit()), _joinCols);
         clearSecondaryTableInfo();
     }
 
@@ -453,10 +455,10 @@
         SequenceMapping seq = (SequenceMapping) getRepository().
             addSequenceMetaData(name);
         seq.setSequencePlugin(SequenceMapping.IMPL_VALUE_TABLE);
-        seq.setTable(toTableName(attrs.getValue("schema"),
+        seq.setTableIdentifier(toTableIdentifier(attrs.getValue("schema"),
             attrs.getValue("table")));
-        seq.setPrimaryKeyColumn(attrs.getValue("pk-column-name"));
-        seq.setSequenceColumn(attrs.getValue("value-column-name"));
+        seq.setPrimaryKeyColumnIdentifier(DBIdentifier.newColumn(attrs.getValue("pk-column-name"), delimit())); 
+        seq.setSequenceColumnIdentifier(DBIdentifier.newColumn(attrs.getValue("value-column-name"), delimit())); 
         seq.setPrimaryKeyValue(attrs.getValue("pk-column-value"));
         String val = attrs.getValue("initial-value");
         if (val != null)
@@ -468,7 +470,7 @@
         Object cur = currentElement();
         Object scope = (cur instanceof ClassMetaData)
             ? ((ClassMetaData) cur).getDescribedType() : null;
-        seq.setSource(getSourceFile(), scope, seq.SRC_XML);
+        seq.setSource(getSourceFile(), scope, SourceTracker.SRC_XML);
         Locator locator = getLocation().getLocator();
         if (locator != null) {
             seq.setLineNumber(Numbers.valueOf(locator.getLineNumber()));
@@ -543,7 +545,7 @@
         if (!StringUtils.isEmpty(temp))
             _mapKeyTemporal = Enum.valueOf(TemporalType.class, temp);
         FieldMapping fm = (FieldMapping) currentElement();
-        List cols = fm.getKeyMapping().getValueInfo().getColumns();
+        List<Column> cols = fm.getKeyMapping().getValueInfo().getColumns();
         if (cols.isEmpty()) {
             cols = Arrays.asList(new Column[]{ new Column() });
             fm.getKeyMapping().getValueInfo().setColumns(cols);
@@ -633,7 +635,7 @@
         if (_lob || _temporal != null) {
             int typeCode = fm.isElementCollection() ? fm.getElement().getDeclaredTypeCode() : 
                 fm.getDeclaredTypeCode();
-            Class type = fm.isElementCollection() ? fm.getElement().getDeclaredType() : fm.getDeclaredType();  
+            Class<?> type = fm.isElementCollection() ? fm.getElement().getDeclaredType() : fm.getDeclaredType();  
             if (_cols == null) {
                 _cols = new ArrayList<Column>(1);
                 _cols.add(new Column());
@@ -665,7 +667,7 @@
         if (_cols != null) {
             switch (fm.getDeclaredTypeCode()) {
                 case JavaTypes.ARRAY:
-                    Class type = fm.getDeclaredType();
+                    Class<?> type = fm.getDeclaredType();
                     if (type == byte[].class || type == Byte[].class
                         || type == char[].class || type == Character[].class ) {
                         fm.getValueInfo().setColumns(_cols);
@@ -680,7 +682,7 @@
                     fm.getValueInfo().setColumns(_cols);
             }
             if (_colTable != null)
-                fm.getMappingInfo().setTableName(_colTable);
+                fm.getMappingInfo().setTableIdentifier(DBIdentifier.newTable(_colTable, delimit()));
             setUnique(fm);
         }
         clearColumnInfo();
@@ -740,7 +742,7 @@
                         getEmbeddedClassType(basefm, _override),
                         basefm, _override, true);
                 dfm._defCols = _cols;
-                dfm._defTable = _colTable;
+                dfm._defTable = DBIdentifier.newTable(_colTable, delimit());
                 dfm._attrName = _override;
                 dfm._unique = _unique;
             }
@@ -748,7 +750,7 @@
         if (fm != null && _cols != null) {
             fm.getValueInfo().setColumns(_cols);
             if (_colTable != null)
-                fm.getMappingInfo().setTableName(_colTable);
+                fm.getMappingInfo().setTableIdentifier(DBIdentifier.newTable(_colTable, delimit()));
             setUnique(fm);
         }
         clearColumnInfo();
@@ -785,10 +787,10 @@
         ClassMapping mapping = (ClassMapping) currentElement();
         if (mapping.isAbstract())
             throw new UserException(_loc.get("table-not-allowed", mapping));
-        String table = toTableName(attrs.getValue("schema"),
+        DBIdentifier table = toTableIdentifier(attrs.getValue("schema"),
             attrs.getValue("name"));
-        if (table != null)
-            mapping.getMappingInfo().setTableName(table);
+        if (!DBIdentifier.isNull(table))
+            mapping.getMappingInfo().setTableIdentifier(table);
         return true;
     }
 
@@ -797,9 +799,9 @@
      */
     private boolean startJoinTable(Attributes attrs)
         throws SAXException {
-        String table = toTableName(attrs.getValue("schema"),
+        DBIdentifier sTable = toTableIdentifier(attrs.getValue("schema"),
             attrs.getValue("name"));
-        if (table != null) {
+        if (!DBIdentifier.isNull(sTable)) {
             Object elem = currentElement();
             FieldMapping fm = null;
             if (elem instanceof FieldMapping) {
@@ -814,7 +816,7 @@
                                 AnnotationPersistenceMappingParser.
                                 getEmbeddedClassType(basefm, _override),
                                 basefm, _override, true);
-                        dfm._defTable = table;
+                        dfm._defTable = sTable.clone();
                         dfm._attrName = _override;
                     }
                 }
@@ -823,7 +825,7 @@
                 fm = getAttributeOverride(cm);
             }
             if (fm != null)
-                fm.getMappingInfo().setTableName(table);
+                fm.getMappingInfo().setTableIdentifier(sTable);
         }
         return true;
     }
@@ -902,7 +904,7 @@
         if (currentParent == COLLECTION_TABLE) {
             FieldMapping fm = (FieldMapping) peekElement();
             Column col = parseColumn(attrs);
-            List colList = new ArrayList();
+            List<Column> colList = new ArrayList<Column>();
             colList.add(col);
             fm.getMappingInfo().setColumns(colList);
             return true;
@@ -930,9 +932,9 @@
             // the column is in a separate table
             if (fm.isElementCollection() &&
                 !fm.getElementMapping().isEmbedded()) {
-                List list = fm.getElementMapping().getValueInfo().getColumns();
+                List<Column> list = fm.getElementMapping().getValueInfo().getColumns();
                 if (list.size() == 0) {
-                    list = new ArrayList();
+                    list = new ArrayList<Column>();
                     fm.getElementMapping().getValueInfo().setColumns(list);
                 }
                 list.add(col);
@@ -949,11 +951,11 @@
      * Parse map-key-column.
      */
     private boolean startMapKeyColumn(Attributes attrs)
-    throws SAXException {
+        throws SAXException {
         FieldMapping fm = (FieldMapping) peekElement();
         Column col = parseColumn(attrs);
         MappingInfo info = fm.getKeyMapping().getValueInfo();
-        List cols = new ArrayList();
+        List<Column> cols = new ArrayList<Column>();
         cols.add(col);
         info.setColumns(cols);
         return true;
@@ -970,10 +972,11 @@
         // or field name, "-", "KEY"
         FieldMapping fm = (FieldMapping) peekElement();
         MappingInfo info = fm.getKeyMapping().getValueInfo();
-        List cols = info.getColumns();
-        Column col = (Column)cols.get(0);
-        if (col.getName() == null)
-            col.setName(fm.getName() + "_" + "KEY");
+        List<Column> cols = info.getColumns();
+        Column col = cols.get(0);
+        if (DBIdentifier.isNull(col.getIdentifier())) {
+            col.setIdentifier(DBIdentifier.newColumn(fm.getName() + "_" + "KEY", delimit()));
+        }
 
         return retVal;
     }
@@ -986,13 +989,13 @@
         Column col = new Column();
         String val = attrs.getValue("name");
         if (val != null)
-            col.setName(val);
+            col.setIdentifier(DBIdentifier.newColumn(val, delimit()));
         val = attrs.getValue("referenced-column-name");
         if (val != null)
-            col.setTarget(val);
+            col.setTargetIdentifier(DBIdentifier.newColumn(val, delimit()));
         val = attrs.getValue("column-definition");
         if (val != null)
-            col.setTypeName(val);
+            col.setTypeIdentifier(DBIdentifier.newColumnDefinition(val));
         val = attrs.getValue("precision");
         if (val != null)
             col.setSize(Integer.parseInt(val));
@@ -1033,38 +1036,30 @@
         FieldMapping fm = (FieldMapping) peekElement();
 
         FieldMappingInfo info = fm.getMappingInfo();
-        Table ctbl = parseCollectionTable(attrs);
-        info.setTableName(toTableName(ctbl.getSchemaName(),
-            ctbl.getName()));
+        DBIdentifier ctbl = parseCollectionTable(attrs);
+        info.setTableIdentifier(ctbl);
         return true;
     }
 
-    private Table parseCollectionTable(Attributes attrs) {
-        Table table = new Table();
-        String val = attrs.getValue("name");
-        if (val != null)
-            table.setName(val);
-        val = attrs.getValue("schema");
-        if (val != null)
-            table.setSchemaName(val);
-        //val = attrs.getValue("catalog");
-        //if (val != null)
-        //    table.setCatalog(val);
-                
-        return table; 
+    private DBIdentifier parseCollectionTable(Attributes attrs) {
+        String tVal = attrs.getValue("name");
+        String sVal = attrs.getValue("schema");
+        return toTableIdentifier(sVal, tVal); 
     }
-  
+
     /**
-     * Return a table name for the given attributes.
+     * Form a qualified table name from a schema and table name.
      */
-    private String toTableName(String schema, String table) {
-        if (StringUtils.isEmpty(table))
-            return null;
-        if (StringUtils.isEmpty(schema))
-            schema = _schema;
-        return (StringUtils.isEmpty(schema)) ? table : schema + "." + table;
+    private DBIdentifier toTableIdentifier(String schema, String table) {
+        DBIdentifier sName = DBIdentifier.newSchema(schema, delimit());
+        DBIdentifier tName = DBIdentifier.newTable(table, delimit());
+        if (DBIdentifier.isEmpty(tName) || DBIdentifier.isEmpty(sName)) {
+            return tName;
+        }
+        return QualifiedDBIdentifier.newPath(sName, tName);
     }
 
+
     /**
      * Start processing <code>sql-result-set-mapping</code> node.
      * Pushes the {@link QueryResultMapping} onto the stack as current element.
@@ -1089,7 +1084,7 @@
         Object cur = currentElement();
         Object scope = (cur instanceof ClassMetaData)
             ? ((ClassMetaData) cur).getDescribedType() : null;
-        result.setSource(getSourceFile(), scope, result.SRC_XML);
+        result.setSource(getSourceFile(), scope, SourceTracker.SRC_XML);
         Locator locator = getLocation().getLocator();
         if (locator != null) {
             result.setLineNumber(Numbers.valueOf(locator.getLineNumber()));
@@ -1111,13 +1106,13 @@
      */
     private boolean startEntityResult(Attributes attrs)
         throws SAXException {
-        Class entityClass = classForName(attrs.getValue("entity-class"));
-        String discriminator = attrs.getValue("discriminator-column");
+        Class<?> entityClass = classForName(attrs.getValue("entity-class"));
+        String discriminator = DBIdentifier.newColumn(attrs.getValue("discriminator-column"), delimit()).getName(); 
 
         QueryResultMapping parent = (QueryResultMapping) currentElement();
         QueryResultMapping.PCResult result = parent.addPCResult(entityClass);
         if (!StringUtils.isEmpty(discriminator))
-            result.addMapping(result.DISCRIMINATOR, discriminator);
+            result.addMapping(PCResult.DISCRIMINATOR, discriminator);
         pushElement(result);
         return true;
     }
@@ -1133,7 +1128,7 @@
     private boolean startFieldResult(Attributes attrs)
         throws SAXException {
         String fieldName = attrs.getValue("name");
-        String columnName = attrs.getValue("column");
+        String columnName = DBIdentifier.newColumn(attrs.getValue("column"), delimit()).getName();
 
         QueryResultMapping.PCResult parent = (QueryResultMapping.PCResult)
             currentElement();
@@ -1161,9 +1156,9 @@
         throws SAXException {
         Unique unique = new Unique();
 
-        String name = attrs.getValue("name");
-        if (StringUtils.isNotEmpty(name)) {
-            unique.setName(name);
+        DBIdentifier name = DBIdentifier.newConstraint(attrs.getValue("name"), delimit());
+        if (!DBIdentifier.isEmpty(name)) {
+            unique.setIdentifier(name);
         }
 
         pushElement(unique);
@@ -1179,26 +1174,26 @@
     private void endUniqueConstraint() {
         Unique unique = (Unique) popElement();
         Object ctx = currentElement();
-        String tableName = "?";
+        DBIdentifier tableName = DBIdentifier.newTable("?");
         if (ctx instanceof ClassMapping) {
         	ClassMappingInfo info = ((ClassMapping) ctx).getMappingInfo();
         	tableName = (_secondaryTable == null) 
-        		? info.getTableName() : _secondaryTable;
+        		? info.getTableIdentifier() : DBIdentifier.newTable(_secondaryTable, delimit());
         	info.addUnique(tableName, unique);
         } else if (ctx instanceof FieldMapping) {// JoinTable
         	FieldMappingInfo info = ((FieldMapping)ctx).getMappingInfo();
         	info.addJoinTableUnique(unique);
         } else if (ctx instanceof SequenceMapping) {
         	SequenceMapping seq = (SequenceMapping)ctx;
-        	unique.setTableName(seq.getTable());
+        	unique.setTableIdentifier(seq.getTableIdentifier());
         	Column[] uniqueColumns = unique.getColumns();
-        	String[] columnNames = new String[uniqueColumns.length];
+        	DBIdentifier[] columnNames = new DBIdentifier[uniqueColumns.length];
         	int i = 0;
         	for (Column uniqueColumn : uniqueColumns)
-        		columnNames[i++] = uniqueColumn.getName();
-        	seq.setUniqueColumns(columnNames);
-        	if (StringUtils.isNotEmpty(unique.getName())) {
-        	    seq.setUniqueConstraintName(unique.getName());
+        		columnNames[i++] = uniqueColumn.getIdentifier().clone();
+        	seq.setUniqueColumnsIdentifier(columnNames);
+        	if (!DBIdentifier.isEmpty(unique.getIdentifier())) {
+        	    seq.setUniqueConstraintIdentifier(unique.getIdentifier());
         	}
         } else {
         	throw new InternalException();
@@ -1214,7 +1209,7 @@
         if (current instanceof Unique) {
             Unique unique = (Unique) current;
             Column column = new Column();
-            column.setName(this.currentText());
+            column.setIdentifier(DBIdentifier.newColumn(this.currentText(), delimit()));
             unique.addColumn(column);
             return true;
         }
@@ -1264,10 +1259,10 @@
         Column col = new Column();
         String val = attrs.getValue("name");
         if (val != null)
-            col.setName(val);
-        val = attrs.getValue("column-definition");
+            col.setIdentifier(DBIdentifier.newColumn(val, delimit()));
+        val = attrs.getValue("column-definition"); 
         if (val != null)
-            col.setTypeName(val);
+            col.setTypeIdentifier(DBIdentifier.newColumnDefinition(val));
         val = attrs.getValue("precision");
         if (val != null)
             col.setSize(Integer.parseInt(val));
@@ -1314,8 +1309,8 @@
             // Apply column, table, and unique overrides
             if (defMap._defCols != null) {
                 fm.getValueInfo().setColumns(defMap._defCols);
-                if (defMap._defTable != null)
-                    fm.getMappingInfo().setTableName(defMap._defTable);
+                if (!DBIdentifier.isNull(defMap._defTable))
+                    fm.getMappingInfo().setTableIdentifier(defMap._defTable);
                 setUnique(fm, defMap._unique);
             }
             // Apply Join column and element join columns overrides overrides
@@ -1334,7 +1329,7 @@
      * Defer overrides for the specified field mapping
      */
     private void deferEmbeddableOverrides(
-        Class cls, DeferredEmbeddableOverrides defMap) {
+        Class<?> cls, DeferredEmbeddableOverrides defMap) {
         ArrayList<DeferredEmbeddableOverrides> defMappings = 
             _deferredMappings.get(cls);
         if (defMappings == null) {
@@ -1401,12 +1396,13 @@
         DeferredEmbeddableOverrides(FieldMapping fm, String attrName) {
             _fm = fm;
             _attrName = attrName;
+            _defTable = DBIdentifier.NULL;
         }
         private FieldMapping _fm;
         private List<Column> _defCols;
         private List<Column> _defElemJoinCols;
         private List<Column> _defJoinCols;
-        private String _defTable;
+        private DBIdentifier _defTable;
         private String _attrName;
         private EnumSet<UniqueFlag> _unique;
     }  
@@ -1415,7 +1411,35 @@
     protected boolean startDelimitedIdentifiers() {
         JDBCConfiguration conf = (JDBCConfiguration) getConfiguration();
         DBDictionary dict = conf.getDBDictionaryInstance();
-        dict.setDelimitIds(true);
+        dict.setDelimitIdentifiers(true);
         return true;
     }
+    
+    @Override
+    protected String normalizeSequenceName(String seqName) {
+        if (StringUtils.isEmpty(seqName)) {
+            return seqName;
+        }
+        return DBIdentifier.newSequence(seqName, delimit()).getName();
+    }
+    
+    @Override
+    protected String normalizeSchemaName(String schName) {
+        if (StringUtils.isEmpty(schName)) {
+            return schName;
+        }
+        return DBIdentifier.newSchema(schName, delimit()).getName();
+    }
+
+    @Override
+    protected String normalizeCatalogName(String catName) {
+        if (StringUtils.isEmpty(catName)) {
+            return catName;
+        }
+        return DBIdentifier.newCatalog(catName, delimit()).getName();
+    }
+
+    private boolean delimit() {
+        return _dict.getDelimitIdentifiers();
+    }
 }

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/delimited/identifiers/Car2.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/delimited/identifiers/Car2.java?rev=899784&r1=899783&r2=899784&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/delimited/identifiers/Car2.java (original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/delimited/identifiers/Car2.java Fri Jan 15 19:38:18 2010
@@ -18,6 +18,7 @@
  */
 package org.apache.openjpa.persistence.delimited.identifiers;
 
+import javax.persistence.Column;
 import javax.persistence.ColumnResult;
 import javax.persistence.DiscriminatorColumn;
 import javax.persistence.Entity;
@@ -28,7 +29,7 @@
 import javax.persistence.SqlResultSetMapping;
 import javax.persistence.Table;
 
-@SqlResultSetMapping(name="CarResultSet",
+@SqlResultSetMapping(name="AnnoCarResultSet",
     entities={@EntityResult(entityClass=Car2.class,
         fields={
         @FieldResult(name="model", column="car model"),

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/delimited/identifiers/EntityA.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/delimited/identifiers/EntityA.java?rev=899784&r1=899783&r2=899784&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/delimited/identifiers/EntityA.java (original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/delimited/identifiers/EntityA.java Fri Jan 15 19:38:18 2010
@@ -62,7 +62,7 @@
     
     @ElementCollection
     @OrderColumn(name="order col")
-    @CollectionTable(name="collection delim set", schema="delim id2")
+    @CollectionTable(name="delim set", schema="delim id2")
     private Set<String> collectionDelimSet = new HashSet<String>();
     
     @ElementCollection

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/delimited/identifiers/TestDelimIdResultSetAnnotations.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/delimited/identifiers/TestDelimIdResultSetAnnotations.java?rev=899784&r1=899783&r2=899784&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/delimited/identifiers/TestDelimIdResultSetAnnotations.java (original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/delimited/identifiers/TestDelimIdResultSetAnnotations.java Fri Jan 15 19:38:18 2010
@@ -52,8 +52,7 @@
             org.apache.openjpa.persistence.delimited.identifiers.Chevrolet.class,
             org.apache.openjpa.persistence.delimited.identifiers.Car2.class,
             org.apache.openjpa.persistence.delimited.identifiers.Pontiac2.class,
-            org.apache.openjpa.persistence.delimited.identifiers.Chevrolet2.class
-            );
+            org.apache.openjpa.persistence.delimited.identifiers.Chevrolet2.class);
         assertNotNull(emf);
         
         em = emf.createEntityManager();
@@ -100,10 +99,10 @@
     
     private void resultSetQuery() {
         String query = 
-            "SELECT c.id, c.\"car model\", c.\"car color\", " +
+            "SELECT c.\"id\", c.\"car model\", c.\"car color\", " +
             "c.\"discr col\", c.\"model year\" " +
             "FROM \"Car\" c ";
-        Query q = em.createNativeQuery(query,"CarResultSet");
+        Query q = em.createNativeQuery(query,"AnnoCarResultSet");
         List<Object[]> results = (List<Object[]>)q.getResultList();
         assertEquals(2,results.size());
         

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/delimited/identifiers/xml/Car.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/delimited/identifiers/xml/Car.java?rev=899784&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/delimited/identifiers/xml/Car.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/delimited/identifiers/xml/Car.java Fri Jan 15 19:38:18 2010
@@ -0,0 +1,90 @@
+/*
+ * 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.
+ */
+package org.apache.openjpa.persistence.delimited.identifiers.xml;
+
+public class Car {
+    private int id;
+    
+    protected String model;
+    protected String color;
+    protected String modelYear;
+
+    public Car() {}
+    
+    public Car(int id) {
+        this.id = id;
+    }
+    
+    /**
+     * @return the id
+     */
+    public int getId() {
+        return id;
+    }
+
+    /**
+     * @param id the id to set
+     */
+    public void setId(int id) {
+        this.id = id;
+    }
+
+    /**
+     * @return the model
+     */
+    public String getModel() {
+        return model;
+    }
+
+    /**
+     * @param model the type to set
+     */
+    public void setModel(String model) {
+        this.model = model;
+    }
+
+    /**
+     * @return the color
+     */
+    public String getColor() {
+        return color;
+    }
+
+    /**
+     * @param color the color to set
+     */
+    public void setColor(String color) {
+        this.color = color;
+    }
+
+    /**
+     * @return the modelYear
+     */
+    public String getModelYear() {
+        return modelYear;
+    }
+
+    /**
+     * @param modelYear the modelYear to set
+     */
+    public void setModelYear(String modelYear) {
+        this.modelYear = modelYear;
+    }
+
+}

Propchange: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/delimited/identifiers/xml/Car.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/delimited/identifiers/xml/Car2.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/delimited/identifiers/xml/Car2.java?rev=899784&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/delimited/identifiers/xml/Car2.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/delimited/identifiers/xml/Car2.java Fri Jan 15 19:38:18 2010
@@ -0,0 +1,99 @@
+/*
+ * 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.
+ */
+package org.apache.openjpa.persistence.delimited.identifiers.xml;
+
+import javax.persistence.ColumnResult;
+import javax.persistence.DiscriminatorColumn;
+import javax.persistence.Entity;
+import javax.persistence.EntityResult;
+import javax.persistence.FieldResult;
+import javax.persistence.Id;
+import javax.persistence.Inheritance;
+import javax.persistence.SqlResultSetMapping;
+import javax.persistence.Table;
+
+//@SqlResultSetMapping(name="CarResultSet",
+//    entities={@EntityResult(entityClass=Car2.class,
+//        fields={
+//        @FieldResult(name="model", column="car model"),
+//        @FieldResult(name="color", column="car color")
+//    },
+//    discriminatorColumn="discr col")},
+//    columns={@ColumnResult(name="model year")})
+//    
+//@Entity
+//@Inheritance
+//@DiscriminatorColumn(name="discr col", columnDefinition="VARCHAR(10)")
+//@Table(name="Car2")
+public class Car2 {
+//    @Id
+    private int id;
+    
+    protected String model;
+    protected String color;
+
+    public Car2() {}
+    
+    public Car2(int id) {
+        this.id = id;
+    }
+    
+    /**
+     * @return the id
+     */
+    public int getId() {
+        return id;
+    }
+
+    /**
+     * @param id the id to set
+     */
+    public void setId(int id) {
+        this.id = id;
+    }
+
+    /**
+     * @return the model
+     */
+    public String getModel() {
+        return model;
+    }
+
+    /**
+     * @param type the type to set
+     */
+    public void setModel(String model) {
+        this.model = model;
+    }
+
+    /**
+     * @return the color
+     */
+    public String getColor() {
+        return color;
+    }
+
+    /**
+     * @param name the name to set
+     */
+    public void setName(String color) {
+        this.color = color;
+    }
+
+}

Propchange: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/delimited/identifiers/xml/Car2.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/delimited/identifiers/xml/Chevrolet.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/delimited/identifiers/xml/Chevrolet.java?rev=899784&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/delimited/identifiers/xml/Chevrolet.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/delimited/identifiers/xml/Chevrolet.java Fri Jan 15 19:38:18 2010
@@ -0,0 +1,28 @@
+/*
+ * 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.
+ */
+package org.apache.openjpa.persistence.delimited.identifiers.xml;
+
+
+public class Chevrolet extends Car {
+    public Chevrolet() {}
+    
+    public Chevrolet(int id) {
+        super(id);
+    }
+}

Propchange: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/delimited/identifiers/xml/Chevrolet.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/delimited/identifiers/xml/Chevrolet2.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/delimited/identifiers/xml/Chevrolet2.java?rev=899784&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/delimited/identifiers/xml/Chevrolet2.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/delimited/identifiers/xml/Chevrolet2.java Fri Jan 15 19:38:18 2010
@@ -0,0 +1,32 @@
+/*
+ * 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.
+ */
+package org.apache.openjpa.persistence.delimited.identifiers.xml;
+
+import javax.persistence.DiscriminatorValue;
+import javax.persistence.Entity;
+
+//@Entity
+//@DiscriminatorValue("Chevrolet")
+public class Chevrolet2 extends Car2 {
+    public Chevrolet2() {}
+    
+    public Chevrolet2(int id) {
+        super(id);
+    }
+}

Propchange: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/delimited/identifiers/xml/Chevrolet2.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message