openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jrba...@apache.org
Subject svn commit: r899784 [1/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/jav...
Date Fri, 15 Jan 2010 19:38:26 GMT
Author: jrbauer
Date: Fri Jan 15 19:38:18 2010
New Revision: 899784

URL: http://svn.apache.org/viewvc?rev=899784&view=rev
Log:
OPENJPA-1115  Remaining delimited identifiers support, including pluggable identifier utility.  Includes code and test contributions from Dianne Richards.

Added:
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/identifier/
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/identifier/ColumnDefIdentifierRule.java   (with props)
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/identifier/DBIdentifier.java   (with props)
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/identifier/DBIdentifierRule.java   (with props)
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/identifier/DBIdentifierUtil.java   (with props)
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/identifier/DBIdentifierUtilImpl.java   (with props)
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/identifier/DefaultIdentifierConfiguration.java   (with props)
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/identifier/Normalizer.java   (with props)
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/identifier/QualifiedDBIdentifier.java   (with props)
    openjpa/trunk/openjpa-jdbc/src/test/java/org/apache/openjpa/jdbc/sql/identifier/
    openjpa/trunk/openjpa-jdbc/src/test/java/org/apache/openjpa/jdbc/sql/identifier/TestDBIdentifiers.java   (with props)
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/delimited/identifiers/xml/
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/delimited/identifiers/xml/Car.java   (with props)
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/delimited/identifiers/xml/Car2.java   (with props)
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/delimited/identifiers/xml/Chevrolet.java   (with props)
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/delimited/identifiers/xml/Chevrolet2.java   (with props)
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/delimited/identifiers/xml/EntityA.java   (with props)
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/delimited/identifiers/xml/EntityB.java   (with props)
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/delimited/identifiers/xml/EntityH.java   (with props)
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/delimited/identifiers/xml/EntityI.java   (with props)
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/delimited/identifiers/xml/EntityI2.java   (with props)
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/delimited/identifiers/xml/EntityI3.java   (with props)
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/delimited/identifiers/xml/EntityI4.java   (with props)
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/delimited/identifiers/xml/Pontiac.java   (with props)
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/delimited/identifiers/xml/Pontiac2.java   (with props)
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/delimited/identifiers/xml/TestXmlDelimIdResultSets.java   (with props)
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/delimited/identifiers/xml/TestXmlDelimIdSeqGen.java   (with props)
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/delimited/identifiers/xml/TestXmlDelimInheritance.java   (with props)
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/delimited/identifiers/xml/TestXmlDelimitedIdentifiers.java   (with props)
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/delimited/identifiers/xml/TestXmlDelimitedJoinAnnotation.java   (with props)
    openjpa/trunk/openjpa-persistence-jdbc/src/test/resources/META-INF/delim_persistence.xml   (with props)
    openjpa/trunk/openjpa-persistence-jdbc/src/test/resources/META-INF/delimited-identifiers-inheritance-xml-orm.xml   (with props)
    openjpa/trunk/openjpa-persistence-jdbc/src/test/resources/META-INF/delimited-identifiers-joins-orm.xml   (with props)
    openjpa/trunk/openjpa-persistence-jdbc/src/test/resources/META-INF/delimited-identifiers-result-set-orm.xml   (with props)
    openjpa/trunk/openjpa-persistence-jdbc/src/test/resources/META-INF/delimited-identifiers-seq-gen-xml-orm.xml   (with props)
    openjpa/trunk/openjpa-persistence-jdbc/src/test/resources/META-INF/delimited-identifiers-xml-orm.xml   (with props)
Modified:
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/conf/JDBCConfiguration.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/conf/JDBCConfigurationImpl.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/ClassTableJDBCSeq.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/MixedLockManager.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/NativeJDBCSeq.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/PreparedStatementManagerImpl.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/TableJDBCSeq.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/ValueTableJDBCSeq.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/PCPath.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/ClassMapping.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/ClassMappingInfo.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/ClassStrategy.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/DelegatingJoinable.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/Discriminator.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/DiscriminatorMappingInfo.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/DiscriminatorStrategy.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/FieldMapping.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/FieldMappingInfo.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/JDBCColumnOrder.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/JDBCOrder.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/JDBCRelatedFieldOrder.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/JDBCValueOrder.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/JavaSQLTypes.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingDefaults.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingDefaultsImpl.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingInfo.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingRepository.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingStrategyInstaller.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingTool.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/NoneMappingDefaults.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/ReverseMappingTool.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/SequenceMapping.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/ValueMapping.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/ValueMappingImpl.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/ValueMappingInfo.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/VersionMappingInfo.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/BlobValueHandler.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/ByteArrayValueHandler.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/CharArrayStreamValueHandler.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/CharArrayValueHandler.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/ClobValueHandler.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/ColumnVersionStrategy.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/ElementEmbedValueHandler.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/EmbedValueHandler.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/EnumValueHandler.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/FlatClassStrategy.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/FullClassStrategy.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/HandlerHandlerMapTableFieldStrategy.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/HandlerRelationMapTableFieldStrategy.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/HandlerStrategies.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/ImmutableValueHandler.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/InValueDiscriminatorStrategy.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/LobFieldStrategy.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/MapTableFieldStrategy.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/MaxEmbeddedLobFieldStrategy.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/ObjectIdValueHandler.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/PrimitiveFieldStrategy.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/RelationFieldStrategy.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/RelationRelationMapTableFieldStrategy.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/RelationStrategies.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/StateComparisonVersionStrategy.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/StringFieldStrategy.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/UntypedPCValueHandler.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/VerticalClassStrategy.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/XMLValueHandler.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/Column.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/ColumnIO.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/Constraint.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/DynamicSchemaFactory.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/ForeignKey.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/Index.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/LazySchemaFactory.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/LocalConstraint.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/NameSet.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/PrimaryKey.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/Schema.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/SchemaGenerator.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/SchemaGroup.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/SchemaTool.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/Schemas.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/Sequence.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/Table.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/TableSchemaFactory.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/Unique.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/XMLSchemaParser.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/XMLSchemaSerializer.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/AbstractSQLServerDictionary.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/AccessDictionary.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/EmpressDictionary.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/FirebirdDictionary.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/FoxProDictionary.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/H2Dictionary.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/HSQLDictionary.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/InformixDictionary.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/IngresDictionary.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/InterbaseDictionary.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/JDataStoreDictionary.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/MySQLDictionary.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/OracleDictionary.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/PointbaseDictionary.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/PostgresDictionary.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/PrimaryRow.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/ResultSetResult.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/RowImpl.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SQLBuffer.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SQLErrorCodeReader.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SQLServerDictionary.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SelectImpl.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SybaseDictionary.java
    openjpa/trunk/openjpa-jdbc/src/main/resources/org/apache/openjpa/jdbc/sql/localizer.properties
    openjpa/trunk/openjpa-persistence-jdbc/src/main/ant/enhancer.xml
    openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/AnnotationPersistenceMappingParser.java
    openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/MappingTag.java
    openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/PersistenceMappingDefaults.java
    openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/XMLPersistenceMappingParser.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/delimited/identifiers/Car2.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/delimited/identifiers/EntityA.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/delimited/identifiers/TestDelimIdResultSetAnnotations.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/resources/META-INF/persistence.xml
    openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/AnnotationPersistenceMetaDataParser.java
    openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/XMLPersistenceMetaDataParser.java

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/conf/JDBCConfiguration.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/conf/JDBCConfiguration.java?rev=899784&r1=899783&r2=899784&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/conf/JDBCConfiguration.java (original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/conf/JDBCConfiguration.java Fri Jan 15 19:38:18 2010
@@ -21,6 +21,7 @@
 import javax.sql.DataSource;
 
 import org.apache.openjpa.conf.OpenJPAConfiguration;
+import org.apache.openjpa.jdbc.identifier.DBIdentifierUtil;
 import org.apache.openjpa.jdbc.kernel.EagerFetchModes;
 import org.apache.openjpa.jdbc.kernel.LRSSizes;
 import org.apache.openjpa.jdbc.kernel.UpdateManager;
@@ -31,6 +32,7 @@
 import org.apache.openjpa.jdbc.sql.DBDictionary;
 import org.apache.openjpa.jdbc.sql.SQLFactory;
 import org.apache.openjpa.kernel.StoreContext;
+import org.apache.openjpa.lib.identifier.IdentifierUtil;
 import org.apache.openjpa.lib.jdbc.ConnectionDecorator;
 import org.apache.openjpa.lib.jdbc.JDBCEvent;
 import org.apache.openjpa.lib.jdbc.JDBCListener;
@@ -592,7 +594,7 @@
      * Return the non-enlisted data source to use. If there is a valid
      * non-xa connection factory configured, then it will be returned. Its
      * default user name and password on calls to
-     * {@link DataSource#getConnection} will be the specificed connection 2
+     * {@link DataSource#getConnection} will be the specified connection 2
      * user name and password. If those are null and the given context is
      * non-null, its user name password will be used instead. If the context
      * is null too, then the user name and password used to retrieve the first
@@ -602,4 +604,23 @@
      * @see #getDataSource
      */
     public DataSource getDataSource2(StoreContext ctx);
+    
+    /**
+     * Gets the String constant that matches the {@link IdentifierUtil}
+     * @return String-based name of the {@link IdentifierUtil}
+     */
+    public String getIdentifierUtil();
+
+    /**
+     * Gets the {@link DBIdentifierUtil}
+     * @return DBIdentifierUtil
+     */
+    public DBIdentifierUtil getIdentifierUtilInstance();
+    
+    /**
+     * Sets the {@link DBIdentifierUtil}
+     * @param util instance of the identifier utility
+     */
+    public void setIdentifierUtil(DBIdentifierUtil util);
+
 }

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/conf/JDBCConfigurationImpl.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/conf/JDBCConfigurationImpl.java?rev=899784&r1=899783&r2=899784&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/conf/JDBCConfigurationImpl.java (original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/conf/JDBCConfigurationImpl.java Fri Jan 15 19:38:18 2010
@@ -24,6 +24,7 @@
 
 import org.apache.commons.lang.StringUtils;
 import org.apache.openjpa.conf.OpenJPAConfigurationImpl;
+import org.apache.openjpa.jdbc.identifier.DBIdentifierUtil;
 import org.apache.openjpa.jdbc.kernel.BatchingConstraintUpdateManager;
 import org.apache.openjpa.jdbc.kernel.BatchingOperationOrderUpdateManager;
 import org.apache.openjpa.jdbc.kernel.EagerFetchModes;
@@ -47,6 +48,7 @@
 import org.apache.openjpa.lib.conf.ProductDerivations;
 import org.apache.openjpa.lib.conf.StringListValue;
 import org.apache.openjpa.lib.conf.StringValue;
+import org.apache.openjpa.lib.identifier.IdentifierUtil;
 import org.apache.openjpa.lib.jdbc.ConnectionDecorator;
 import org.apache.openjpa.lib.jdbc.DecoratingDataSource;
 import org.apache.openjpa.lib.jdbc.JDBCListener;
@@ -82,6 +84,7 @@
     public ObjectValue mappingDefaultsPlugin;
     public PluginValue driverDataSourcePlugin;
     public MappingFactoryValue mappingFactoryPlugin;
+    public ObjectValue identifierUtilPlugin;
 
     // used internally
     private String firstUser = null;
@@ -331,6 +334,15 @@
         finderCachePlugin.setDynamic(true);
         finderCachePlugin.setInstantiatingGetter("getFinderCacheInstance");
 
+        identifierUtilPlugin = addPlugin("jdbc.IdentifierUtil", true);
+        aliases = new String[] { 
+            "default", "org.apache.openjpa.jdbc.identifier.DBIdentifierUtilImpl" };
+        identifierUtilPlugin.setAliases(aliases);
+        identifierUtilPlugin.setDefault(aliases[0]);
+        identifierUtilPlugin.setString(aliases[0]);
+        identifierUtilPlugin.setInstantiatingGetter("getIdentifierUtilInstance");
+
+        
         // this static initializer is to get past a weird
         // ClassCircularityError that happens only under IBM's
         // JDK 1.3.1 on Linux from within the JRun ClassLoader;
@@ -899,4 +911,19 @@
                 return true; 
         return false;
     }
+    
+    public String getIdentifierUtil() {
+        return identifierUtilPlugin.getString();
+    }
+
+    public DBIdentifierUtil getIdentifierUtilInstance() {
+        if (identifierUtilPlugin.get() == null)
+            identifierUtilPlugin.instantiate(DBIdentifierUtil.class, this);
+        return (DBIdentifierUtil) identifierUtilPlugin.get();
+    }
+
+    public void setIdentifierUtil(DBIdentifierUtil util) {
+        identifierUtilPlugin.set(util);
+    }
+
 }

Added: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/identifier/ColumnDefIdentifierRule.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/identifier/ColumnDefIdentifierRule.java?rev=899784&view=auto
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/identifier/ColumnDefIdentifierRule.java (added)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/identifier/ColumnDefIdentifierRule.java Fri Jan 15 19:38:18 2010
@@ -0,0 +1,39 @@
+/*
+ * 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.jdbc.identifier;
+
+import org.apache.openjpa.jdbc.identifier.DBIdentifier.DBIdentifierType;
+
+/**
+ * Default rule for column definition.  This rule disables delimiting of
+ * column definitions.  Column definitions can be extremely tricky to 
+ * delimit correctly.  Blindly delimiting them causes failures on most
+ * databases.  Where user defined types are concerned, generally they don't
+ * need to be delimited and if so, they are more appropriately delimited
+ * when they are specified.
+ */
+public class ColumnDefIdentifierRule extends DBIdentifierRule {
+
+    public ColumnDefIdentifierRule() {
+        super();
+        setName(DBIdentifierType.COLUMN_DEFINITION.toString());
+        // Disable auto delimiting of column definition.
+        setCanDelimit(false);
+    }
+}

Propchange: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/identifier/ColumnDefIdentifierRule.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/identifier/DBIdentifier.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/identifier/DBIdentifier.java?rev=899784&view=auto
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/identifier/DBIdentifier.java (added)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/identifier/DBIdentifier.java Fri Jan 15 19:38:18 2010
@@ -0,0 +1,911 @@
+/*
+ * 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.jdbc.identifier;
+
+import java.io.Serializable;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.openjpa.lib.identifier.Identifier;
+import org.apache.openjpa.lib.identifier.IdentifierImpl;
+
+/**
+ * Encapsulates a database identifier.  With a few exceptions, this class is 
+ * intended to treated as immutable.  
+ */
+public class DBIdentifier extends IdentifierImpl implements Cloneable, Identifier, Serializable {
+
+    /**
+     * Database identifier types.
+     */
+    public enum DBIdentifierType {
+        DEFAULT,
+        TABLE,
+        SCHEMA,
+        CATALOG,
+        DATABASE,
+        COLUMN,
+        COLUMN_DEFINITION,
+        SEQUENCE,
+        CONSTRAINT,
+        INDEX,
+        FOREIGN_KEY,
+        CONSTANT,
+        NULL
+    }
+    
+    // Array for quick compound identifier determination.  Compound identifiers
+    // can have multi-part names, such as {schema, table} and should be stored
+    // as a QualifiedDBIdentifier.
+    private static boolean _compoundIdentifier[] = new boolean[DBIdentifierType.values().length];
+    
+    static {
+        _compoundIdentifier[DBIdentifierType.TABLE.ordinal()] = true;
+        _compoundIdentifier[DBIdentifierType.COLUMN.ordinal()] = true;
+        _compoundIdentifier[DBIdentifierType.SEQUENCE.ordinal()] = true;
+        _compoundIdentifier[DBIdentifierType.CONSTRAINT.ordinal()] = true;
+        _compoundIdentifier[DBIdentifierType.INDEX.ordinal()] = true;
+    }
+    
+    private DBIdentifierType _type = DBIdentifierType.DEFAULT;
+    
+    /**
+     * Special NULL indicator for db identifiers.
+     */
+    public static final DBIdentifier NULL = new DBIdentifier(DBIdentifierType.NULL);
+    
+    // All constructors are protected or private.  Static factory operations
+    // should be used to construct new identifiers.
+    protected DBIdentifier() {
+    }
+
+    private DBIdentifier(DBIdentifierType type) {
+        setType(type);
+    }
+
+    protected DBIdentifier(String name, DBIdentifierType type) {
+        setType(type);
+        setName(name);
+    }
+
+    protected DBIdentifier(String name, DBIdentifierType type, boolean delimit) {
+        setType(type);
+        setName(name, delimit);
+    }
+    
+    protected DBIdentifier(String name, boolean delimit) {
+        setName(name, delimit);
+    }
+
+
+    /**
+     * Set the name of the identifier.
+     */
+    public void setName(String name) {
+        setName(name, false);
+    }
+
+    /**
+     * Set the name of this identifier based upon a given identifier.
+     */
+    public void setName(DBIdentifier name) {
+        assertNotNull();
+        if (DBIdentifier.isNull(name)) {
+            setNameInternal(null);
+            setType(name.getType());
+            return;
+        }
+        setNameInternal(name.getNameInternal());
+        setType(name.getType());
+    }
+
+    /**
+     * Set the name of the identifier and optionally force delimiting of the identifier. 
+     */
+    public void setName(String name, boolean delimit) {
+        assertNotNull();
+        
+        // Normalize the name, if necessary.  Do not normalize constants or column definitions.
+        if (DBIdentifierType.CONSTANT != getType() && DBIdentifierType.COLUMN_DEFINITION != getType()) {
+            if (delimit) {
+                name = Normalizer.delimit(name, true);
+             } else {
+                 name = Normalizer.normalizeString(name);
+             }
+        }
+        super.setName(name);
+    }
+    
+    /**
+     * Set the type of the identifier
+     * @param type
+     */
+    protected void setType(DBIdentifierType type) {
+        _type = type;
+    }
+
+    /**
+     * Get the identifier type
+     * @return the identifier type
+     */
+    public DBIdentifierType getType() {
+        return _type;
+    }
+    
+
+    /**
+     * Splits a string delimited by the specified delimiter of a given name type
+     * into an array of DBIdentifier objects.
+     * Example:  COL1|"COL 2"|COL3  delim=| --> DBIdentifier[]{ COL1, "COL 2", COL3 }
+     * @param name
+     * @param id
+     * @param delim
+     * @return
+     */
+    public static DBIdentifier[] split(String name, DBIdentifierType id, String delim) {
+        
+        if (!Normalizer.canSplit(name, delim)) {
+            return new DBIdentifier[] { new DBIdentifier(name, id) };
+        }
+        
+        String[] names = Normalizer.splitName(name, delim);
+        if (names.length == 0) {
+            return new DBIdentifier[] { };
+        }
+        DBIdentifier[] sNames = new DBIdentifier[names.length];
+        for (int i = 0; i < names.length ; i++) {
+            sNames[i] = new DBIdentifier(names[i], id);
+        }
+        return sNames;
+    }
+    
+    /**
+     * Joins the list of identifiers using the appropriate delimiters and
+     * returns a string based identifier.
+     * @param resultId
+     * @param names
+     * @return
+     */
+    public static String join(DBIdentifier...names) {
+        if (names == null || names.length == 0) {
+            return null;
+        }
+        String[] strNames = new String[names.length];
+        for (int i = 0; i < names.length; i++) {
+            strNames[i] = names[i].getNameInternal();
+        }
+        return Normalizer.joinNames(strNames);
+    }
+    /**
+     * Splits a given DBIdentifier into multiple DBIdentifiers.  Uses the base name 
+     * type and heuristics to determine the types and placement of the resulting
+     * components.
+     * @param name
+     * @return
+     */
+    public static DBIdentifier[] split(DBIdentifierType resultType, String name) {
+        
+        String[] names = Normalizer.splitName(name);
+        switch (names.length) {
+            case 2:
+                return getTwoPartIdentifier(names, resultType);
+            case 3:
+                return getThreePartIdentifier(names, resultType);
+            case 4:
+                return getFourPartIdentifier(names, resultType);
+            default:
+                return new DBIdentifier[] { new DBIdentifier(name, resultType) };
+        }
+    }
+
+    /*
+     * Returns a two-part identifier based upon the base identifier type.
+     */
+    private static DBIdentifier[] getTwoPartIdentifier(String[] names, DBIdentifierType baseId) {
+        DBIdentifier[] sNames = new DBIdentifier[2];
+        DBIdentifierType id0 = DBIdentifierType.DEFAULT;
+        DBIdentifierType id1 = baseId;
+        if (baseId != DBIdentifierType.COLUMN &&
+                baseId != DBIdentifierType.SCHEMA) {
+            id0 = DBIdentifierType.SCHEMA;
+        }
+        else if (baseId == DBIdentifierType.COLUMN) {
+            // Length 2, base name column
+            id0 = DBIdentifierType.TABLE;
+        }
+        else if (baseId == DBIdentifierType.SCHEMA) {
+            id0 = DBIdentifierType.DATABASE;
+        }
+        sNames[0] = new DBIdentifier(names[0], id0);
+        sNames[1] = new DBIdentifier(names[1], id1);
+        return sNames;
+    }
+
+    /*
+     * Returns a three-part identifier based upon the base identifier type.
+     */
+    private static DBIdentifier[] getThreePartIdentifier(String[] names, DBIdentifierType baseId) {
+        DBIdentifier[] sNames = new DBIdentifier[3];
+        DBIdentifierType id0 = DBIdentifierType.DEFAULT;
+        DBIdentifierType id1 = DBIdentifierType.DEFAULT;
+        DBIdentifierType id2 = baseId;
+        if (baseId != DBIdentifierType.SCHEMA &&
+            baseId != DBIdentifierType.COLUMN) {
+            id0 = DBIdentifierType.DATABASE;
+            id1 = DBIdentifierType.SCHEMA;
+        }
+        else if (baseId == DBIdentifierType.COLUMN) {
+            // Length 2, base name column
+            id0 = DBIdentifierType.SCHEMA;
+            id1 = DBIdentifierType.TABLE;
+        }
+        sNames[0] = new DBIdentifier(names[0], id0);
+        sNames[1] = new DBIdentifier(names[1], id1);
+        sNames[2] = new DBIdentifier(names[2], id2);
+        return sNames;
+    }
+
+    /*
+     * Returns a four-part identifier based upon the base identifier type.
+     */
+    private static DBIdentifier[] getFourPartIdentifier(String[] names, DBIdentifierType baseId) {
+        DBIdentifier[] sNames = new DBIdentifier[4];
+        DBIdentifierType id0 = DBIdentifierType.DEFAULT;
+        DBIdentifierType id1 = DBIdentifierType.DEFAULT;
+        DBIdentifierType id2 = DBIdentifierType.DEFAULT;
+        DBIdentifierType id3 = baseId;
+        if (baseId == DBIdentifierType.COLUMN) {
+            id0 = DBIdentifierType.DATABASE;
+            id1 = DBIdentifierType.SCHEMA;
+            id2 = DBIdentifierType.TABLE;
+        }
+        sNames[0] = new DBIdentifier(names[0], id0);
+        sNames[1] = new DBIdentifier(names[1], id1);
+        sNames[2] = new DBIdentifier(names[2], id2);
+        sNames[3] = new DBIdentifier(names[3], id3);
+        return sNames;
+    }
+
+    /**
+     * Returns true if the identifier is null or the name is null or empty.
+     * @param name
+     * @return
+     */
+    public static boolean isEmpty(DBIdentifier name) {
+        if (isNull(name)) {
+            return true;
+        }
+        return StringUtils.isEmpty(name.getName());
+    }
+
+    
+    /**
+     * Returns true if the identifier is null.
+     * @param name
+     * @return
+     */
+    public static boolean isNull(DBIdentifier name) {
+        return (name == null || name.getType() == DBIdentifierType.NULL);
+    }
+
+    /**
+     * Clones an identifier using deep copy.
+     */
+    public DBIdentifier clone() {
+        DBIdentifier sName = new DBIdentifier();
+        sName.setNameInternal(getNameInternal());
+        sName.setType(getType());
+        return sName;
+    }
+    
+    /*
+     * Internal method to set the base name and avoid normalizing an already 
+     * normalized name.
+     * @param name
+     */
+    private void setNameInternal(String name) {
+        super.setName(name);
+    }
+
+    /*
+     * Internal method to get the base name. 
+     * normalized name.
+     * @param name
+     */
+    private String getNameInternal() {
+        return super.getName();
+    }
+
+    /**
+     * Returns a copy of an identifier with name trimmed to null.
+     * @param name
+     * @return
+     */
+    public static DBIdentifier trimToNull(DBIdentifier name) {
+        if (DBIdentifier.isNull(name)) {
+            return name;
+        }
+        DBIdentifier sName = name.clone();
+        sName.setNameInternal(StringUtils.trimToNull(sName.getNameInternal()));
+        return sName;
+    }
+
+    /**
+     * Equality operation for identifiers.  Supports comparison with strings
+     * and objects of this type.
+     */
+    public boolean equals(Object obj) {
+        if (obj == null) {
+            return false;
+        }
+        if (obj == this) {
+            return true;
+        }
+        if (obj instanceof DBIdentifier) {
+            DBIdentifier sName = (DBIdentifier)obj;
+            return this.equals(sName, false);
+        } else if (obj instanceof String) {
+            return obj.equals(this.getNameInternal());
+        }
+        throw new IllegalArgumentException("Unsupported type comparison: " + obj.getClass().getName());
+    }
+
+    /**
+     * Returns true if this object is NULL or has a null name component.
+     * @return
+     */
+    public boolean isNull() {
+        return (_type == DBIdentifierType.NULL || getName() == null);
+    }
+
+    /**
+     * Comparison operator for identifiers.
+     */
+    public int compareTo(Identifier o) {
+        if (o instanceof DBIdentifier) {
+            if (this == DBIdentifier.NULL && (o == null || o == DBIdentifier.NULL)) {
+                return 0;
+            }
+            if (this == DBIdentifier.NULL)
+                return 1;
+            if (o == null || o == DBIdentifier.NULL)
+                return -1;
+        }
+        return super.compareTo(o);
+    }
+    
+
+    /**
+     * Converts the provided set of names to an array of identifiers of the 
+     * provided type
+     * @param columnNames
+     * @param id
+     * @return
+     */
+    public static DBIdentifier[] toArray(String[] columnNames, DBIdentifierType id) {
+        return toArray(columnNames, id, false);
+    }
+
+    /**
+     * Converts the provided set of names to an array of identifiers of the 
+     * provided type, optionally delimiting the names.
+     * @param columnNames
+     * @param id
+     * @return
+     */
+    public static DBIdentifier[] toArray(String[] names, DBIdentifierType id, boolean delimit) {
+        if (names == null) {
+            return null;
+        }
+        DBIdentifier[] sNames = new DBIdentifier[names.length];
+        for (int i = 0; i < names.length; i++) {
+            sNames[i] = new DBIdentifier(names[i], id, delimit);
+        }
+        return sNames;
+    }
+    
+    /**
+     * Returns a string array of names based upon the provided set of identifiers.
+     * @param sNames
+     * @return
+     */
+    public static String[] toStringArray(DBIdentifier[] sNames) {
+        if (sNames == null) {
+            return null;
+        }
+        String[] names = new String[sNames.length];
+        for (int i = 0; i < sNames.length; i++) {
+            names[i] = sNames[i].getName();
+        }
+        return names;
+    }
+
+    /**
+     * Constructs a new identifier of type Catalog.
+     */
+    public static DBIdentifier newCatalog(String name) {
+        return newIdentifier(name, DBIdentifierType.CATALOG);
+    }
+
+    /**
+     * Constructs a new identifier of type Catalog ,optionally delimiting
+     * the name.
+     */
+    public static DBIdentifier newCatalog(String name, boolean delimit) {
+        return newIdentifier(name, DBIdentifierType.CATALOG, false, delimit);
+    }
+    
+    /**
+     * Constructs a new identifier of type Table.
+     */
+    public static DBIdentifier newTable(String name) {
+        return newIdentifier(name, DBIdentifierType.TABLE);
+    }
+
+    /**
+     * Constructs a new identifier of type Table, optionally delimiting
+     * the name.
+     */
+    public static DBIdentifier newTable(String name, boolean delimit) {
+        return newIdentifier(name, DBIdentifierType.TABLE, false, delimit);
+    }
+    
+    /**
+     * Constructs a new identifier of type Column.
+     */
+    public static DBIdentifier newColumn(String name) {
+        return newIdentifier(name, DBIdentifierType.COLUMN);
+    }
+
+    /**
+     * Constructs a new identifier of type Column,optionally delimiting
+     * the name.
+     */
+    public static DBIdentifier newColumn(String name, boolean delimit) {
+        return newIdentifier(name, DBIdentifierType.COLUMN, false, delimit);
+    }
+
+    /**
+     * Constructs a new identifier of type Schema.
+     */
+    public static DBIdentifier newSchema(String name) {
+        return newIdentifier(name, DBIdentifierType.SCHEMA);
+    }
+
+    /**
+     * Constructs a new identifier of type Schema, optionally delimiting
+     * the name.
+     */
+    public static DBIdentifier newSchema(String name, boolean delimit) {
+        return newIdentifier(name, DBIdentifierType.SCHEMA, false, delimit);
+    }
+
+    /**
+     * Constructs a new identifier of type Index.
+     */
+    public static DBIdentifier newIndex(String name) {
+        return newIdentifier(name, DBIdentifierType.INDEX);
+    }
+
+    /**
+     * Constructs a new identifier of type Index, optionally delimiting
+     * the name.
+     */
+    public static DBIdentifier newIndex(String name, boolean delimit) {
+        return newIdentifier(name, DBIdentifierType.INDEX, false, delimit);
+    }
+
+    /**
+     * Constructs a new identifier of type Sequence.
+     */
+    public static DBIdentifier newSequence(String name) {
+        return newIdentifier(name, DBIdentifierType.SEQUENCE);
+    }
+
+    /**
+     * Constructs a new identifier of type Sequence, optionally delimiting
+     * the name.
+     */
+    public static DBIdentifier newSequence(String name, boolean delimit) {
+        return newIdentifier(name, DBIdentifierType.SEQUENCE, false, delimit);
+    }
+
+    /**
+     * Constructs a new identifier of type ForeignKey.
+     */
+    public static DBIdentifier newForeignKey(String name) {
+        return newIdentifier(name, DBIdentifierType.FOREIGN_KEY);
+    }
+
+    /**
+     * Constructs a new identifier of type ForeignKey, optionally delimiting
+     * the name.
+     */
+    public static DBIdentifier newForeignKey(String name, boolean delimit) {
+        return newIdentifier(name, DBIdentifierType.FOREIGN_KEY, false, delimit);
+    }
+
+    /**
+     * Constructs a new identifier of type Constraint.
+     */
+    public static DBIdentifier newConstraint(String name) {
+        return newIdentifier(name, DBIdentifierType.CONSTRAINT);
+    }
+
+    /**
+     * Constructs a new identifier of type Constraint, optionally delimiting
+     * the name.
+     */
+    public static DBIdentifier newConstraint(String name, boolean delimit) {
+        return newIdentifier(name, DBIdentifierType.CONSTRAINT, false, delimit);
+    }
+
+    /**
+     * Constructs a new identifier of type Constant.
+     */
+    public static DBIdentifier newConstant(String name) {
+        return newIdentifier(name, DBIdentifierType.CONSTANT);
+    }
+
+    /**
+     * Constructs a new identifier of type Column Definition.
+     */
+    public static DBIdentifier newColumnDefinition(String name) {
+        return newIdentifier(name, DBIdentifierType.COLUMN_DEFINITION);
+    }
+
+    /**
+     * Constructs a new identifier of type Default.
+     */
+    public static DBIdentifier newDefault(String name) {
+        return newIdentifier(name, DBIdentifierType.DEFAULT);
+    }
+
+    /**
+     * Constructs a new identifier with the provided name and type
+     */
+    protected static DBIdentifier newIdentifier(String name, DBIdentifierType id) {
+        return newIdentifier(name, id, false, false);
+    }
+
+    /**
+     * Constructs a new identifier with the provided name an type. Optionally,
+     * converting the name to upper case.
+     */
+    public static DBIdentifier newIdentifier(String name, DBIdentifierType id, boolean toUpper) {
+        return newIdentifier(name, id, toUpper, false );
+    }
+
+    /**
+     * Constructs a new identifier (potentially a compound QualifiedDBIdentifier) with the provided 
+     * name an type. Optionally, converting the name to upper case and delimiting it.
+     */
+    protected static DBIdentifier newIdentifier(String name, DBIdentifierType id, boolean toUpper, boolean delimit) {
+        if (name == null) {
+            return DBIdentifier.NULL;
+        }
+        
+        DBIdentifier dbId = DBIdentifier.NULL;
+        // Create a DBIDentifier for single component names.  Otherwise, create a QualifiedDBIdentifier.
+        if (!_compoundIdentifier[id.ordinal()] || delimit) {
+            dbId = new DBIdentifier(name, id, delimit);
+            if (toUpper) {
+                return toUpper(dbId);
+            }
+        } else {
+            // Name can be split. Break it up into components and return a path
+            DBIdentifier[] sNames = DBIdentifier.split(id, name);
+            dbId = new QualifiedDBIdentifier(sNames);
+        }
+        return dbId;
+    }
+
+    /**
+     * Static equality method for comparing two identifiers.
+     * @param name1
+     * @param name2
+     * @return
+     */
+    public static boolean equal(DBIdentifier name1, DBIdentifier name2) {
+        boolean name1Null = DBIdentifier.isNull(name1);
+        if (name1Null && DBIdentifier.isNull(name2)) {
+            return true;
+        }
+        if (name1Null) {
+            return false;
+        }
+        return ((DBIdentifier)name1).equals(name2, false);
+    }
+
+    
+    private void assertNotNull() {
+        if (this == DBIdentifier.NULL || getType() == DBIdentifierType.NULL) {
+            throw new IllegalStateException("Cannot modify NULL instance");
+        }
+    }
+    
+    /**
+     * Returns a new DBIdentifier truncated to length
+     * @param name
+     * @param length
+     * @return
+     */
+    public static DBIdentifier truncate(DBIdentifier name, int length) {
+        DBIdentifier sName = name.clone();
+        String strName = sName.getNameInternal();
+        if (StringUtils.isEmpty(strName)) {
+            return sName;
+        }
+        strName = Normalizer.truncate(strName, length);
+        sName.setNameInternal(strName);
+        return sName;
+    }
+
+    /**
+     * Returns a new DBIdentifier with the given string appended.
+     * @param name
+     * @param length
+     * @return
+     */
+    public static DBIdentifier append(DBIdentifier name, String str) {
+        DBIdentifier sName = name.clone();
+        String strName = sName.getNameInternal();
+        strName = Normalizer.append(strName, str);
+        sName.setNameInternal(strName);
+        return sName;
+    }
+
+    /**
+     * Returns a new DBIdentifier with the given string combined using 
+     * delimiting rules and appropriate separators.
+     * @param name
+     * @param length
+     * @return
+     */
+    public static DBIdentifier combine(DBIdentifier name, String str) {
+        DBIdentifier sName = name.clone();
+        String strName = sName.getNameInternal();
+        strName = Normalizer.combine(strName, str);
+        sName.setNameInternal(strName);
+        return sName;
+    }
+
+    /**
+     * Returns a new DBIdentifier converted to lower case - if not delimited.
+     * @param name
+     * @return
+     */
+    public static DBIdentifier toLower(DBIdentifier name) {
+        return toLower(name, false);
+    }
+    
+    /**
+     * Returns a new DBIdentifier converted to lower case.  If delimited,
+     * force to lower case using force option.
+     * @param name
+     * @return
+     */
+    public static DBIdentifier toLower(DBIdentifier name, boolean force) {
+        if (DBIdentifier.isNull(name)) {
+            return name;
+        }
+        DBIdentifier sName = name.clone();
+        if (sName.getNameInternal() == null) {
+            return sName;
+        }
+        // Do not convert delimited names to lower case.  They may have
+        // been delimited to preserve case.
+        if (force || !Normalizer.isDelimited(sName.getNameInternal())) {
+            sName.setNameInternal(sName.getNameInternal().toLowerCase());
+        }
+        return sName;
+    }
+
+    /**
+     * Returns a new DBIdentifier converted to upper case - if not delimited.
+     * @param name
+     * @return
+     */
+    public static DBIdentifier toUpper(DBIdentifier name) {
+        return toUpper(name, false);
+    }
+
+    /**
+     * Returns a new DBIdentifier converted to upper case.  If delimited,
+     * force to upper case using force option.
+     * @param name
+     * @return
+     */
+    public static DBIdentifier toUpper(DBIdentifier name, boolean force) {
+        if (DBIdentifier.isNull(name)) {
+            return name;
+        }
+        DBIdentifier sName = name.clone();
+        if (sName.getNameInternal() == null) {
+            return sName;
+        }
+        // Do not convert delimited names to upper case.  They may have
+        // been delimited to preserve case.
+        if (force || !Normalizer.isDelimited(sName.getNameInternal())) {
+            sName.setNameInternal(sName.getNameInternal().toUpperCase());
+        }
+        return sName;
+    }
+
+    /**
+     * Returns a new DBIdentifier with the specified leading string removed.
+     * @param name
+     * @return
+     */
+    public static DBIdentifier removeLeading(DBIdentifier name, String leadingStr) {
+        DBIdentifier sName = name.clone();
+        if (isEmpty(sName)) {
+            return sName;
+        }
+        String strName = sName.getNameInternal();
+        int leadingLen = leadingStr.length();
+        while (strName.startsWith(leadingStr)) {
+            strName = strName.substring(leadingLen);
+        }
+        sName.setNameInternal(strName);
+        return sName;
+    }
+    
+    /**
+     * Returns a new DBIdentifier with Hungarian notation removed.
+     * @param name
+     * @return
+     */
+    public static DBIdentifier removeHungarianNotation(DBIdentifier name) {
+        DBIdentifier hName = name.clone();
+        if (isEmpty(hName)) {
+            return hName;
+        }
+        String strName = hName.getNameInternal();
+        strName = Normalizer.removeHungarianNotation(strName);
+        hName.setNameInternal(strName);
+        return hName;
+    }
+
+    /**
+     * Equality operator which ignores case.
+     * @param name
+     * @return
+     */
+   public boolean equalsIgnoreCase(DBIdentifier name) {
+       return equals(name, true);
+   }
+
+   /**
+    * Static equality operator which ignores case.
+    * @param name
+    * @return
+    */
+    public static boolean equalsIgnoreCase(DBIdentifier name1, DBIdentifier name2) {
+        boolean name1Null = DBIdentifier.isNull(name1);
+        if (name1Null && DBIdentifier.isNull(name2)) {
+            return true;
+        }
+        if (name1Null) {
+            return false;
+        }
+        return name1.equals(name2, true);
+    }
+
+    private boolean equals(DBIdentifier sName, boolean ignoreCase) {
+        if (sName.getNameInternal() == null && getNameInternal() == null) {
+            return true;
+        }
+        if (getNameInternal() == null) {
+            return false;
+        }
+        if (ignoreCase || !Normalizer.isDelimited(getNameInternal())) {
+            return getNameInternal().equalsIgnoreCase(sName.getNameInternal());
+        }
+        return getNameInternal().equals(sName.getNameInternal());
+    }
+
+    /**
+     * Returns a new identifier with a combined prefix and name using the standard name
+     * concatenation character ('_').
+     * @param prefix
+     */
+    public static DBIdentifier preCombine(DBIdentifier name, String prefix) {
+        if (DBIdentifier.isNull(name)) {
+            return name;
+        }
+        DBIdentifier sName = name.clone();
+        String strName = sName.getNameInternal();
+        strName = Normalizer.combine(prefix, strName);
+        sName.setNameInternal(strName);
+        return sName;
+    }
+
+    /**
+     * Returns a new identifier with delimiters removed.
+     * @param name
+     * @return
+     */
+    public static DBIdentifier removeDelimiters(DBIdentifier name) {
+        if (DBIdentifier.isNull(name)) {
+            return name;
+        }
+        DBIdentifier sName = name.clone();
+        if (isEmpty(sName)) {
+            return sName;
+        }
+        String strName = sName.getNameInternal();
+        strName = Normalizer.removeDelimiters(strName);
+        sName.setNameInternal(strName);
+        return sName;
+    }
+
+    /**
+     * Returns a new delimiter with leading and trailing spaces removed.
+     * @param name
+     * @return
+     */
+    public static DBIdentifier trim(DBIdentifier name) {
+        if (DBIdentifier.isNull(name)) {
+            return name;
+        }
+        DBIdentifier sName = name.clone();
+        if (isEmpty(sName)) {
+            return sName;
+        }
+        String strName = sName.getNameInternal();
+        strName = strName.trim();
+        sName.setNameInternal(strName);
+        return sName;
+    }
+
+    /**
+     * The length of the name, including delimiting characters.
+     */
+    public int length() {
+        if (DBIdentifier.isNull(this)) {
+            return 0;
+        }
+        return super.length();
+    }
+
+    /**
+     * Returns true if the identifier is delimited.
+     */
+    public boolean isDelimited() {
+        if (DBIdentifier.isEmpty(this)) {
+            return false;
+        }
+        return Normalizer.isDelimited(getNameInternal());
+    }
+
+    /**
+     * Combines an array of names names using standard combining rules and
+     * returns an identifier of the specified type.
+     */
+    public static DBIdentifier combine(DBIdentifierType id, String...names) {
+        return newIdentifier(Normalizer.combine(names), id);
+    }
+
+    /**
+     * Returns the unqualified name of this identifier.
+     */
+    public DBIdentifier getUnqualifiedName() {
+        return this;
+    }
+}

Propchange: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/identifier/DBIdentifier.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/identifier/DBIdentifierRule.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/identifier/DBIdentifierRule.java?rev=899784&view=auto
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/identifier/DBIdentifierRule.java (added)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/identifier/DBIdentifierRule.java Fri Jan 15 19:38:18 2010
@@ -0,0 +1,56 @@
+/*
+ * 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.jdbc.identifier;
+
+import java.util.Set;
+
+import org.apache.openjpa.jdbc.identifier.DBIdentifier.DBIdentifierType;
+import org.apache.openjpa.lib.identifier.IdentifierRule;
+
+/**
+ * The default DBIdentifier rule.  Closely matches SQL92 naming rules.
+ */
+public class DBIdentifierRule extends IdentifierRule {
+    
+    public static final String DEFAULT_SQL_92 = "DefaultSQL92";
+    
+    public static final String SPECIAL_CHARS = " #$&%!?,.:;\"\'";
+    
+    public DBIdentifierRule() {
+        setName(DEFAULT_SQL_92);
+        // SQL92 Identifier rule 1) Can be up to 128 characters long
+//        setMaxLength(128);
+        // OpenJPA allows names with a length of 255 by default
+        setMaxLength(255);
+        // SQL92 Identifier rule 2) Must begin with a letter
+        setMustBeginWithLetter(true);
+        // SQL92 Identifier rule 3) Can contain letters, digits, and underscores
+        setOnlyLettersDigitsUnderscores(true);
+        // SQL Identifier rule 4) Can't contain spaces or special characters such 
+        // as #, $, &, %, or punctuation.
+        setSpecialCharacters(SPECIAL_CHARS);
+    }
+
+    public DBIdentifierRule(DBIdentifierType id, Set<String> reservedWords) {
+        this();
+        setName(id.toString());
+        // SQL Identifier rule 5) Can't be reserved words
+        setReservedWords(reservedWords);
+    }
+}

Propchange: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/identifier/DBIdentifierRule.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/identifier/DBIdentifierUtil.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/identifier/DBIdentifierUtil.java?rev=899784&view=auto
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/identifier/DBIdentifierUtil.java (added)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/identifier/DBIdentifierUtil.java Fri Jan 15 19:38:18 2010
@@ -0,0 +1,213 @@
+/*
+ * 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.jdbc.identifier;
+
+import org.apache.openjpa.jdbc.schema.Column;
+import org.apache.openjpa.jdbc.schema.NameSet;
+import org.apache.openjpa.jdbc.schema.Schema;
+import org.apache.openjpa.jdbc.schema.Table;
+import org.apache.openjpa.lib.identifier.IdentifierUtil;
+
+import static org.apache.openjpa.jdbc.identifier.DBIdentifier.DBIdentifierType;
+
+/**
+ * An interface for DB identifier utility-style operations.  This interface
+ * extends the basic operations provided by IdentifierUtil with additional
+ * operations those specific to DBIdentifiers and identifier conversion.
+ */
+public interface DBIdentifierUtil extends IdentifierUtil {
+
+    // Legacy values for naming operations
+    public static final int ANY = 0;
+    public static final int TABLE = 1;
+    public static final int SEQUENCE = 2;
+    public static final int COLUMN = 3;
+
+    /**
+     * Shortens the given name to the given maximum length, then checks that
+     * it is not a reserved word. If it is reserved, appends a "0". If
+     * the name conflicts with an existing schema component and uniqueness
+     * checking is enabled, the last character is replace with '0', then 
+     * '1', etc. 
+     * Note that the given max len may be 0 if the database metadata is 
+     * incomplete.
+     * 
+     * Note: If the name is delimited, make sure the ending delimiter is
+     * not stripped off.
+     */
+    public DBIdentifier makeIdentifierValid(DBIdentifier sname, NameSet set, int maxLen,
+        boolean checkForUniqueness);
+
+    /**
+     * Shortens the given name to the given maximum length, then checks that
+     * it is not a reserved word. If it is reserved, appends a "0". If
+     * the name conflicts with an existing schema component and uniqueness
+     * checking is enabled, the last character is replace with '0', then 
+     * '1', etc. 
+     * Note that the given max len may be 0 if the database metadata is 
+     * incomplete.
+     * 
+     * Note: If the name is delimited, make sure the ending delimiter is
+     * not stripped off.
+     */
+    public DBIdentifier makeNameValid(String name, NameSet set, int maxLen,
+        int nameType, boolean checkForUniqueness);
+
+    /**
+     * Returns a valid column name/identifier, based upon the configuration and
+     * provided parameters.
+     * @param name
+     * @param table
+     * @param maxLen
+     * @param checkForUniqueness
+     * @return
+     */
+    public DBIdentifier getValidColumnIdentifier(DBIdentifier name, Table table, int maxLen, 
+        boolean checkForUniqueness);
+    
+    /**
+     * Returns a valid index identifier, based upon the configuration and
+     * provided parameters.
+     * @param name
+     * @param table
+     * @param maxLen
+     * @param checkForUniqueness
+     * @return
+     */
+    public DBIdentifier getValidIndexIdentifier(DBIdentifier name, Table table, int maxLen);
+
+    /**
+     * Returns a valid index identifier, based upon the configuration and
+     * provided parameters.
+     * @param name
+     * @param table
+     * @param maxLen
+     * @param checkForUniqueness
+     * @return
+     */
+    public DBIdentifier getValidSequenceIdentifier(DBIdentifier name, Schema schema, int maxLen);
+    
+    /**
+     * Returns a valid table identifier, based upon the configuration and provided
+     * parameters.
+     * @param name
+     * @param schema
+     * @param maxLen
+     * @return
+     */
+    public DBIdentifier getValidTableIdentifier(DBIdentifier name, Schema schema, int maxLen);
+
+    /**
+     * Returns a valid unique constraint identifier, based upon the configuration and
+     * provided parameters.
+     * @param name
+     * @param table
+     * @param maxLen
+     * @return
+     */
+    public DBIdentifier getValidUniqueIdentifier(DBIdentifier name, Table table, int maxLen);
+
+    /**
+     * Returns a valid foreign key identifier, based upon the configuration and
+     * provided parameters.
+     * @param name
+     * @param table
+     * @param toTable
+     * @param maxLen
+     * @return
+     */
+    public DBIdentifier getValidForeignKeyIdentifier(DBIdentifier name, Table table, Table toTable, int maxLen);
+
+    /**
+     * Converts the specified identifier to a format required by the database.
+     * @param name
+     * @return
+     */
+    public String toDBName(DBIdentifier name);
+
+    /**
+     * Converts the specified identifier to a format required by the database, 
+     * optionally delimiting the name.
+     * @param name
+     * @param delimit
+     * @return
+     */
+    public String toDBName(DBIdentifier name, boolean delimit);
+
+    /**
+     * Converts the specified string to a format required by the database.
+     * @param name
+     * @return
+     */
+    public String toDBName(String name);
+
+    /**
+     * Converts the specified string to a format required by the database,
+     * optionally delimiting the name.
+     * @param name
+     * @return
+     */
+    public String toDBName(String name, boolean delimit);
+
+    /**
+     * Converts the name returned by the database to an identifier of the
+     * specified type.
+     * @param name
+     * @return
+     */
+    public DBIdentifier fromDBName(String name, DBIdentifierType id);
+
+    /**
+     * Appends multiple columns names together into comma delimited string.
+     * @param columns
+     * @return
+     */
+    public String appendColumns(Column[] columns);
+
+    /**
+     * Converts the name of the specified delimiter to the appropriate
+     * case as defined by the configuration.
+     * @param columns
+     * @return
+     */
+    public DBIdentifier convertSchemaCase(DBIdentifier schema);
+
+    /**
+     * Appends multiple names together using the appropriate name delimiter.
+     * @param resultId
+     * @param names
+     * @return
+     */
+    public DBIdentifier append(DBIdentifierType resultId, DBIdentifier...names);
+
+    /**
+     * Returns a generated key sequence identifier for the column.
+     * @param col
+     * @param maxLen
+     * @return
+     */
+    public DBIdentifier getGeneratedKeySequenceName(Column col, int maxLen);
+
+    /**
+     * Converts a provided alias to a format specified in the configuration.
+     * @param alias
+     * @return
+     */
+    public String convertAlias(String alias);
+}

Propchange: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/identifier/DBIdentifierUtil.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/identifier/DBIdentifierUtilImpl.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/identifier/DBIdentifierUtilImpl.java?rev=899784&view=auto
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/identifier/DBIdentifierUtilImpl.java (added)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/identifier/DBIdentifierUtilImpl.java Fri Jan 15 19:38:18 2010
@@ -0,0 +1,478 @@
+/*
+ * 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.jdbc.identifier;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.openjpa.jdbc.conf.JDBCConfiguration;
+import org.apache.openjpa.jdbc.identifier.DBIdentifier.DBIdentifierType;
+import org.apache.openjpa.jdbc.schema.Column;
+import org.apache.openjpa.jdbc.schema.NameSet;
+import org.apache.openjpa.jdbc.schema.Schema;
+import org.apache.openjpa.jdbc.schema.SchemaGroup;
+import org.apache.openjpa.jdbc.schema.Table;
+import org.apache.openjpa.jdbc.sql.DBDictionary;
+import org.apache.openjpa.lib.conf.Configurable;
+import org.apache.openjpa.lib.conf.Configuration;
+import org.apache.openjpa.lib.identifier.IdentifierConfiguration;
+import org.apache.openjpa.lib.identifier.IdentifierRule;
+import org.apache.openjpa.lib.identifier.IdentifierUtil;
+import org.apache.openjpa.lib.identifier.IdentifierUtilImpl;
+
+public class DBIdentifierUtilImpl extends IdentifierUtilImpl implements DBIdentifierUtil,
+    Configurable {
+    
+    private JDBCConfiguration _conf = null;
+
+    public DBIdentifierUtilImpl() {
+    }
+    
+    public DBIdentifierUtilImpl(IdentifierConfiguration config) {
+        super(config);
+    }
+    
+    public DBIdentifier getValidColumnIdentifier(DBIdentifier name, Table table,
+        int maxLen, boolean checkForUniqueness) {
+        if (DBIdentifier.isNull(name)) {
+            return name;
+        }
+        String rule = name.getType().name();
+        maxLen = getMaxLen(rule, name, maxLen);
+
+        DBIdentifier sName = DBIdentifier.removeLeading(name, IdentifierUtil.UNDERSCORE);
+        return makeIdentifierValid(sName, table, maxLen, checkForUniqueness);
+    }
+    
+    public DBIdentifier getValidForeignKeyIdentifier(DBIdentifier name, Table table, Table toTable, int maxLen) {
+        if (DBIdentifier.isNull(name)) {
+            return name;
+        }
+        String rule = name.getType().name();
+        maxLen = getMaxLen(rule, name, maxLen);
+
+        DBIdentifier sName = makeName(rule, name, table, "F");
+        return makeIdentifierValid(sName, table.getSchema().getSchemaGroup(),
+            maxLen, true);
+    }
+
+    
+    public DBIdentifier getValidUniqueIdentifier(DBIdentifier name, Table table, int maxLen) {
+        if (DBIdentifier.isNull(name)) {
+            return name;
+        }
+        String rule = name.getType().name();
+        maxLen = getMaxLen(rule, name, maxLen);
+
+        DBIdentifier sName = makeName(rule, name, table, "U");
+        return makeIdentifierValid(sName, table.getSchema().getSchemaGroup(),
+            maxLen, true);
+    }
+
+    public DBIdentifier getValidIndexIdentifier(DBIdentifier name, Table table, int maxLen) {
+        if (DBIdentifier.isNull(name)) {
+            return name;
+        }
+        String rule = name.getType().name();
+        maxLen = getMaxLen(rule, name, maxLen);
+
+        DBIdentifier sName = makeName(rule, name, table, "I");
+        return makeIdentifierValid(sName, table.getSchema().getSchemaGroup(),
+            maxLen, true);
+    }
+
+    public DBIdentifier getValidSequenceIdentifier(DBIdentifier name, Schema schema, int maxLen) {
+        if (DBIdentifier.isNull(name)) {
+            return name;
+        }
+        String rule = name.getType().name();
+        maxLen = getMaxLen(rule, name, maxLen);
+
+        DBIdentifier sName = makeName(rule, name, "S");
+        return makeIdentifierValid(sName, schema.getSchemaGroup(), maxLen, true);
+    }
+
+    public DBIdentifier getValidTableIdentifier(DBIdentifier name, Schema schema, int maxLen) {
+        if (DBIdentifier.isNull(name)) {
+            return name;
+        }
+        String rule = name.getType().name();
+        maxLen = getMaxLen(rule, name, maxLen);
+
+        DBIdentifier sName = makeName(rule, name, null);
+        
+        return makeIdentifierValid(sName, schema.getSchemaGroup(),
+            maxLen, true);
+    }
+
+    public DBIdentifier makeNameValid(String name, NameSet set, int maxLen,
+        int nameType, boolean checkForUniqueness) {
+        DBIdentifierType id = DBIdentifierType.DEFAULT;
+        switch (nameType) {
+            case DBIdentifierUtil.TABLE:
+                id = DBIdentifierType.TABLE;
+                break;
+            case DBIdentifierUtil.SEQUENCE:
+                id = DBIdentifierType.SEQUENCE;
+                break;
+            case DBIdentifierUtil.COLUMN:
+                id = DBIdentifierType.COLUMN;
+                break;
+        }
+        return makeIdentifierValid(DBIdentifier.newIdentifier(name, id), set, maxLen, checkForUniqueness);
+    }
+
+    public DBIdentifier makeIdentifierValid(DBIdentifier sname, NameSet set, int maxLen,
+        boolean checkForUniqueness) {
+        DBIdentifier validName = sname;
+        String rule = sname.getType().name();
+        
+        maxLen = getMaxLen(rule, validName, maxLen);
+
+        int nameLen = validName.getName().length();
+        if (nameLen > maxLen) {
+            validName = DBIdentifier.truncate(validName, nameLen - maxLen);
+            nameLen = validName.getName().length();
+        }
+        if (isReservedWord(rule, validName.getName())) {
+            if (nameLen == maxLen)
+                validName = DBIdentifier.truncate(validName, 1);
+            validName = DBIdentifier.append(validName, "0");
+            nameLen = validName.getName().length();
+        }
+
+        // now make sure the name is unique
+        if (set != null && checkForUniqueness) {
+            for (int version = 1, chars = 1; true; version++) {
+                // for table names, we check for the table itself in case the
+                // name set is lazy about schema reflection
+                if (validName.getType() == DBIdentifierType.TABLE) {
+                    if (!((SchemaGroup) set).isKnownTable(QualifiedDBIdentifier.getPath(validName)))
+                        break;
+                } else if (validName.getType() == DBIdentifierType.SEQUENCE) {
+                    if (!((SchemaGroup) set).isKnownSequence(QualifiedDBIdentifier.getPath(validName)))
+                        break;
+                } else {
+                    if (!set.isNameTaken(validName))
+                        break;
+                }
+
+                // a single char for the version is probably enough, but might
+                // as well be general about it...
+                if (version > 1) {
+                    validName = DBIdentifier.truncate(validName, chars);
+                }
+                if (version >= Math.pow(10, chars))
+                    chars++;
+                if (nameLen + chars > maxLen) {
+                    validName = DBIdentifier.truncate(validName, nameLen + chars - maxLen);
+                }
+                validName = DBIdentifier.append(validName, Integer.toString(version)); 
+                nameLen = validName.getName().length();
+            }
+        }
+        
+        if (validName.isDelimited()) {
+            String delimCase = getIdentifierConfiguration().getDelimitedCase();
+            if (delimCase.equals(CASE_LOWER)) {
+                return DBIdentifier.toLower(validName,true);
+            }
+            else if (delimCase.equals(CASE_UPPER)) {
+                return DBIdentifier.toUpper(validName,true);
+            }
+            else {
+                return validName;
+            }
+        }
+        return DBIdentifier.toUpper(validName);
+    }
+
+    /**
+     *  Converts the name to a name which can be used within a SQL statement.  Uses
+     *  the appropriate delimiters and separators. 
+     *  @parm name a DBIdentifier
+     */
+    public String toDBName(DBIdentifier name) {
+        return toDBName(name, true);
+    }
+    
+    /**
+     *  Converts the name to a name which can be used within a SQL statement.  Uses
+     *  the appropriate delimiters and separators. 
+     *  @parm name a DBIdentifier
+     *  @param delimit If true, allows the name to be delimited, if necessary.  
+     *  Otherwise, the identifier is not delimited.
+     */
+    public String toDBName(DBIdentifier name, boolean delimit) {
+        if (DBIdentifier.isNull(name)) {
+            return null;
+        }
+        if (getIdentifierConfiguration().getSupportsDelimitedIdentifiers() && delimit 
+            && getIdentifierConfiguration().delimitAll() && !name.isDelimited()) {
+            return delimit(name, true);
+        }
+        String rule = name.getType().name();
+        if (name instanceof QualifiedDBIdentifier) {
+            QualifiedDBIdentifier path = (QualifiedDBIdentifier)name;
+            return convertFull(Normalizer.getNamingConfiguration(), rule, path.getName());
+        }
+        return convert(Normalizer.getNamingConfiguration(), rule, name.getName());
+    }
+
+    /**
+     * Converts the identifier to a format appropriate for the configuration.
+     * Delimits if necessary
+     */
+    public String toDBName(String name) {
+        return toDBName(name, true);
+    }
+
+    /**
+     * Converts the identifier to a format appropriate for the configuration using
+     * the default naming rule.
+     * @param delimit If false, do not delimit.  Otherwise, delimit if necessary.
+     */
+    public String toDBName(String name, boolean delimit) {
+        return toDBName(getIdentifierConfiguration().getDefaultIdentifierRule().getName(), name, delimit);
+    }
+
+    /**
+     * Converts the identifier to a format appropriate for the configuration using
+     * the specified naming rule.
+     * @param delimit If false, do not delimit.  Otherwise, delimit if necessary.
+     */
+    private String toDBName(String rule, String name, boolean delimit) {
+        if (name == null) {
+            return null;
+        }
+        if (getIdentifierConfiguration().getSupportsDelimitedIdentifiers() && delimit && 
+            getIdentifierConfiguration().delimitAll() && !Normalizer.isDelimited(name)) {
+            return delimit(rule, name, true);
+        }
+        return convert(Normalizer.getNamingConfiguration(), rule, name);
+    }
+
+    /**
+     * Creates a new identifier of a given type based upon the name returned
+     * from the database.  
+     */
+    public DBIdentifier fromDBName(String name, DBIdentifierType id) {
+        if (name == null) {
+            return DBIdentifier.NULL;
+        }
+        if (!getIdentifierConfiguration().getSupportsDelimitedIdentifiers()) {
+            return DBIdentifier.newIdentifier(name, id);
+        }
+        String delimCase = getIdentifierConfiguration().getDelimitedCase();
+        String nonDelimCase = getIdentifierConfiguration().getSchemaCase();
+        String caseName = name;
+        
+        // If delimited and non-delimited case are the same, don't change 
+        // case or try to determine whether delimiting is required.  Let the
+        // normalizer figure it out using standard rules.
+        if (delimCase.equals(nonDelimCase)) {
+            return DBIdentifier.newIdentifier(name, id, false, false);
+        }
+        
+        // Otherwise, try to determine whether to delimit based on an expected vs.
+        // actual name comparison.
+        if (delimCase.equals(CASE_PRESERVE)) {
+            if (nonDelimCase.equals(CASE_LOWER)) {
+                caseName = name.toLowerCase();
+            } else {
+                caseName = name.toUpperCase();
+            }
+        } else if (delimCase.equals(CASE_LOWER)) {
+            if (nonDelimCase.equals(CASE_UPPER)) {
+                caseName = name.toUpperCase();
+            }
+        } else if (delimCase.equals(CASE_UPPER)) {
+            if (nonDelimCase.equals(CASE_LOWER)) {
+                caseName = name.toLowerCase();
+            }
+        }
+        
+        boolean delimit = !caseName.equals(name) || getIdentifierConfiguration().delimitAll();
+        return DBIdentifier.newIdentifier((delimit ? name : caseName), id, false, delimit);
+    }
+
+    public DBIdentifier append(DBIdentifierType resultId, DBIdentifier...names) {
+        if (names == null || names.length == 0) {
+            return DBIdentifier.NULL;
+        }
+        DBIdentifier sName = DBIdentifier.newIdentifier("", resultId);
+        for (DBIdentifier name : names) {
+            DBIdentifier.append(sName, name.getName());
+        }
+        return sName;
+    }
+    
+    public String appendColumns(Column[] columns) {
+        if (columns == null || columns.length == 0) {
+            return "";
+        }
+        if (columns.length == 1) {
+            return toDBName(columns[0].getIdentifier());
+        }
+        StringBuilder colsb = new StringBuilder("");
+        for (int i = 0; i < columns.length; i++) {
+            colsb.append(toDBName(columns[i].getIdentifier()));
+            if (i < (columns.length - 1)) {
+                colsb.append(", ");
+            }
+        }
+        return colsb.toString();
+    }
+    
+    public String delimit(DBIdentifier name, boolean force) {
+        String rule = name.getType().name();
+        // If this is a compound path, each item must be delimited
+        // separately
+        if (name instanceof QualifiedDBIdentifier) {
+            QualifiedDBIdentifier path = (QualifiedDBIdentifier)name;
+            // Make sure this is a qualified path before delimiting
+            // separately
+            if (!((path.getType() == DBIdentifierType.COLUMN &&
+                  path.isUnqualifiedColumn()) ||
+                  (path.getType() != DBIdentifierType.COLUMN &&
+                   path.isUnqualifiedObject()))) {
+                DBIdentifier[] names = QualifiedDBIdentifier.splitPath(name);
+                for (int i = 0; i < names.length; i++) {
+                    DBIdentifier sName = names[i].getUnqualifiedName();
+                    if (!sName.isDelimited()) {
+                        String pRule = sName.getType().name();
+                        names[i].setName(delimit(pRule, sName.getName(), force));
+                    }
+                }
+                return QualifiedDBIdentifier.newPath(names).getName();
+            }
+        }
+        return delimit(rule, name.getName(), force);
+    }
+    
+    public String shorten(String name, int targetLength) {
+        return DBDictionary.shorten(name, targetLength);
+    }
+    
+    public DBIdentifier getGeneratedKeySequenceName(Column col, int maxLen) {
+        DBIdentifier tname = col.getTableIdentifier();
+        DBIdentifier cname = col.getIdentifier();
+        int max = maxLen;
+        int extraChars = -max + tname.getName().length() + 1 // <tname> + '_'
+            + cname.getName().length() + 4; // <cname> + '_SEQ'
+        String tsname = tname.getName();
+        if (extraChars > 0) {
+            // this assumes that tname is longer than extraChars
+            tsname = tsname.substring(0, tsname.length() - extraChars);
+        }
+        return DBIdentifier.combine(DBIdentifierType.SEQUENCE, tsname, cname.getName(), "SEQ");
+    }
+    
+    /**
+     * Convert the specified schema name to a name that the database will
+     * be able to understand in metadata operations.
+     */
+    public DBIdentifier convertSchemaCase(DBIdentifier name) {
+        if (DBIdentifier.isNull(name))
+            return DBIdentifier.NULL;
+
+        DBIdentifier sName = name.clone();
+        // Handle delimited string differently. Return unquoted name.
+        String delimCase = getIdentifierConfiguration().getDelimitedCase();
+        if (/* getNamingConfiguration().delimitAll() || */ name.isDelimited()) {
+            if (CASE_UPPER.equals(delimCase)) {
+                sName = DBIdentifier.toUpper(sName,true);
+            }
+            else if (CASE_LOWER.equals(delimCase)) {
+                sName = DBIdentifier.toLower(sName,true);
+            }
+            
+            return DBIdentifier.removeDelimiters(sName);
+        }
+        if (!getIdentifierConfiguration().delimitAll()) {
+            // Not delimited, use the base schema case expected by the DB
+            String schemaCase = getIdentifierConfiguration().getSchemaCase();
+            if (CASE_LOWER.equals(schemaCase))
+                return DBIdentifier.toLower(sName);
+            if (CASE_PRESERVE.equals(schemaCase))
+                return sName;
+            return DBIdentifier.toUpper(sName);
+        }
+        return sName;
+    }
+    
+    /**
+     * Converts a column alias to use the appropriate delimiters
+     */
+    public String convertAlias(String alias) {
+        String[] names = Normalizer.splitName(alias);
+        if (names.length <= 1) {
+            // Nothing to split
+            return alias;
+        }
+        // Skip the the first name.  It is the alias (T0, T1, etc.)
+        for (int i = 1; i < names.length; i++) {
+            names[i] = toDBName(getIdentifierConfiguration().getDefaultIdentifierRule().toString(), names[i], true);
+        }
+        return joinNames(getIdentifierConfiguration().getDefaultIdentifierRule(), names);
+    }
+
+    private DBIdentifier makeName(String rule, DBIdentifier name, Table tbl, String prefix) {
+        DBIdentifier sName = DBIdentifier.removeLeading(name, IdentifierUtil.UNDERSCORE);
+        String tableName = tbl.getIdentifier().getName();
+        int len = Math.min(tableName.length(), 7);
+        
+        String str = combineNames(rule, new String[] { prefix == null ? "" : prefix, 
+            shorten(tableName, len), sName.getName() });
+        sName.setName(str);
+        return sName;
+    }
+
+    private DBIdentifier makeName(String rule, DBIdentifier name, String prefix) {
+        DBIdentifier sName = DBIdentifier.removeLeading(name, IdentifierUtil.UNDERSCORE);
+        if (!StringUtils.isEmpty(prefix)) {
+            sName = DBIdentifier.preCombine(sName, prefix);
+        }
+        return sName;
+    }
+
+    private int getMaxLen(String rule, DBIdentifier name, int maxLen) {
+        IdentifierConfiguration config = getIdentifierConfiguration();
+        if (maxLen < 1) {
+            IdentifierRule nrule = config.getIdentifierRule(rule);
+            maxLen = nrule.getMaxLength();
+        }
+        // Subtract delimiter length if name is delimited or will be delimited
+        if (config.delimitAll() || name.isDelimited()) {
+            maxLen = maxLen - (config.getLeadingDelimiter().length() + config.getTrailingDelimiter().length());
+        }
+        
+        return maxLen;
+    }
+    
+    /**
+     * System configuration.
+     */
+    public JDBCConfiguration getConfiguration() {
+        return _conf;
+    }
+
+    @Override
+    public void setConfiguration(Configuration conf) {
+        _conf = (JDBCConfiguration)conf;
+    }
+}

Propchange: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/identifier/DBIdentifierUtilImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message