================================================================================
Merge Diffs: /ade/tware_toplink10i/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/tests/FullRegressionTestSuite.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1072_table_generation_wonsoek_kim_061107/ade_storage/000001/AB0952363AC40CBFE034080020E8C54E.25
Report generated at Tue Nov  7 10:57:21 2006
--------------------------------------------------------------------------------
*** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1072_table_generation_wonsoek_kim_061107/ade_storage/000001/AB0952363AC40CBFE034080020E8C54E.25	Mon Nov  6 14:11:37 2006
--- /ade/tware_toplink10i/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/tests/FullRegressionTestSuite.java	Tue Nov  7 10:57:21 2006
***************
*** 63,70 ****
  import oracle.toplink.essentials.testing.tests.ejb.ejbqltesting.JUnitEJBQLModifyTestSuite;
  
  import oracle.toplink.essentials.testing.tests.cmp3.xml.EntityMappingsJUnitTestSuite;
  import oracle.toplink.essentials.testing.tests.ejb.ejbqltesting.JUnitEJBQLInheritanceTestSuite;
- import oracle.toplink.essentials.testing.tests.cmp3.instancecounting.MemoryLeakJUnitTestSuite;
  
  public class FullRegressionTestSuite extends TestSuite{
      
--- 63,70 ----
  import oracle.toplink.essentials.testing.tests.ejb.ejbqltesting.JUnitEJBQLModifyTestSuite;
  
  import oracle.toplink.essentials.testing.tests.cmp3.xml.EntityMappingsJUnitTestSuite;
+ import oracle.toplink.essentials.testing.tests.cmp3.ddlgeneration.DDLGenerationJUnitTestSuite;
  import oracle.toplink.essentials.testing.tests.ejb.ejbqltesting.JUnitEJBQLInheritanceTestSuite;
  
  public class FullRegressionTestSuite extends TestSuite{
      
***************
*** 113,121 ****
          fullSuite.addTest(QueryParameterValidationTestSuite.suite());
          fullSuite.addTest(UniAndBiDirectionalMappingTestSuite.suite());
          
-         // Instance Counting Model
-         fullSuite.addTest(MemoryLeakJUnitTestSuite.suite());
-         
          // EJBQL testing model
          fullSuite.addTest(JUnitEJBQLUnitTestSuite.suite());
          fullSuite.addTest(JUnitEJBQLSimpleTestSuite.suite());
--- 113,118 ----
***************
*** 131,136 ****
--- 128,136 ----
          // XML model
          fullSuite.addTest(EntityMappingsJUnitTestSuite.suite());
  
+         // DDL model
+         fullSuite.addTest(DDLGenerationJUnitTestSuite.suite());
+ 
          return fullSuite;
      }
      
================================================================================
Merge Diffs: /ade/tware_toplink10i/tldev/source/essentials/oracle/toplink/essentials/tools/schemaframework/TableDefinition.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1072_table_generation_wonsoek_kim_061107/ade_storage/000002/AB0952363AC40CBFE034080020E8C54E.9
Report generated at Tue Nov  7 10:57:21 2006
--------------------------------------------------------------------------------
*** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1072_table_generation_wonsoek_kim_061107/ade_storage/000002/AB0952363AC40CBFE034080020E8C54E.9	Mon Nov  6 14:28:26 2006
--- /ade/tware_toplink10i/tldev/source/essentials/oracle/toplink/essentials/tools/schemaframework/TableDefinition.java	Tue Nov  7 10:57:21 2006
***************
*** 27,32 ****
--- 27,33 ----
  import oracle.toplink.essentials.internal.databaseaccess.*;
  import oracle.toplink.essentials.exceptions.*;
  import oracle.toplink.essentials.internal.sessions.AbstractSession;
+ import oracle.toplink.essentials.queryframework.SQLCall;
  
  /**
   * <p>
***************
*** 34,41 ****
   * <p>
   */
  public class TableDefinition extends DatabaseObjectDefinition {
!     protected Vector fields;
!     protected Vector foreignKeys;
      protected Vector uniqueKeys;
      protected String creationPrefix;
      protected String creationSuffix;
--- 35,42 ----
   * <p>
   */
  public class TableDefinition extends DatabaseObjectDefinition {
!     protected Vector fields; //FieldDefinitions
!     protected HashMap<String, ForeignKeyConstraint> foreignKeyMap; //key is the name of ForeignKeyConstraint
      protected Vector uniqueKeys;
      protected String creationPrefix;
      protected String creationSuffix;
***************
*** 43,49 ****
  
      public TableDefinition() {
          this.fields = new Vector();
!         this.foreignKeys = new Vector();
          this.uniqueKeys = new Vector();
          this.creationPrefix = "CREATE TABLE ";
          this.creationSuffix = "";
--- 44,50 ----
  
      public TableDefinition() {
          this.fields = new Vector();
!         this.foreignKeyMap = new HashMap<String, ForeignKeyConstraint>();
          this.uniqueKeys = new Vector();
          this.creationPrefix = "CREATE TABLE ";
          this.creationSuffix = "";
***************
*** 96,101 ****
--- 97,103 ----
      /**
       * PUBLIC:
       * Add a foreign key constraint to the table.
+      * If there is a same name foreign key constraint already, nothing will happen.
       */
      public void addForeignKeyConstraint(String name, String sourceField, String targetField, String targetTable) {
          ForeignKeyConstraint foreignKey = new ForeignKeyConstraint(name, sourceField, targetField, targetTable);
***************
*** 114,122 ****
      /**
       * PUBLIC:
       * Add a foreign key constraint to the table.
       */
      public void addForeignKeyConstraint(ForeignKeyConstraint foreignKey) {
!         getForeignKeys().addElement(foreignKey);
      }
      
      /**
--- 116,127 ----
      /**
       * PUBLIC:
       * Add a foreign key constraint to the table.
+      * If there is a same name foreign key constraint already, nothing will happen.
       */
      public void addForeignKeyConstraint(ForeignKeyConstraint foreignKey) {
!         if (!foreignKeyMap.containsKey(foreignKey.getName())) {
!             foreignKeyMap.put(foreignKey.getName(), foreignKey);
!         }
      }
      
      /**
***************
*** 371,384 ****
      private void buildForeignFieldTypes(final AbstractSession session) {
          Hashtable fieldTypes = session.getPlatform().getClassTypes();
          FieldDefinition field = null;
-         DatabaseField dbField = null;
          
!         Vector foreignKeysClone = (Vector)getForeignKeys().clone();          
!         setForeignKeys(new Vector());
          for (Enumeration enumtr = getFields().elements(); enumtr.hasMoreElements();) {
              field = (FieldDefinition)enumtr.nextElement();
              if (field.getForeignKeyFieldName() != null) {
!                 addForeignKeyConstraint(buildForeignKeyConstraint(field, this, session.getPlatform()));
  
              }
              if (field.getType() == null) {
--- 376,390 ----
      private void buildForeignFieldTypes(final AbstractSession session) {
          Hashtable fieldTypes = session.getPlatform().getClassTypes();
          FieldDefinition field = null;
          
!         // The ForeignKeyConstraint object is the newer way of doing things.
!         // We support FieldDefinition.getForeignKeyFieldName() due to backwards compatibility
!         // by converting it. To allow mixing both ways, we just add converted one to foreignKeys list.
!         
          for (Enumeration enumtr = getFields().elements(); enumtr.hasMoreElements();) {
              field = (FieldDefinition)enumtr.nextElement();
              if (field.getForeignKeyFieldName() != null) {
!                 addForeignKeyConstraint(buildForeignKeyConstraint(field, session.getPlatform()));
  
              }
              if (field.getType() == null) {
***************
*** 389,403 ****
              }
          }
  
-         /* bug #2997188 constraints not getting generated when creating/replacing tables via TableCreator
-            had to add the next few lines instead of removing the above code for backwards compatibility */
-         if (getForeignKeys().isEmpty()) {
-             //if foreignKeys is empty then we know we are not in 2.5
-             setForeignKeys(foreignKeysClone);
-         }
      }
  
!     protected ForeignKeyConstraint buildForeignKeyConstraint(FieldDefinition field, TableDefinition table, DatabasePlatform platform) {
          Vector sourceFields = new Vector();
          Vector targetFields = new Vector();
          ForeignKeyConstraint fkConstraint = new ForeignKeyConstraint();
--- 395,406 ----
              }
          }
  
      }
  
!     /**
!      * Build a foriegn key constraint using FieldDefinition.getForeignKeyFieldName().
!      */
!     protected ForeignKeyConstraint buildForeignKeyConstraint(FieldDefinition field, DatabasePlatform platform) {
          Vector sourceFields = new Vector();
          Vector targetFields = new Vector();
          ForeignKeyConstraint fkConstraint = new ForeignKeyConstraint();
***************
*** 410,422 ****
          fkConstraint.setSourceFields(sourceFields);
          fkConstraint.setTargetFields(targetFields);
          fkConstraint.setTargetTable(tempTargetField.getTable().getQualifiedName());
!         String tempName = buildForeignKeyConstraintName(table.getName(), tempSourceField.getName(), platform.getMaxForeignKeyNameSize());
  
          fkConstraint.setName(tempName);
          return fkConstraint;
      }
  
      /**
       * Return foreign key constraint name built from the table and field name with the specified maximum length. To
       * make the name short enough we
       * 1. Drop the "FK_" prefix.
--- 413,445 ----
          fkConstraint.setSourceFields(sourceFields);
          fkConstraint.setTargetFields(targetFields);
          fkConstraint.setTargetTable(tempTargetField.getTable().getQualifiedName());
!         String tempName = buildForeignKeyConstraintName(this.getName(), tempSourceField.getName(), platform.getMaxForeignKeyNameSize());
  
          fkConstraint.setName(tempName);
          return fkConstraint;
      }
  
      /**
+      * Build a foriegn key constraint.
+      */
+     protected ForeignKeyConstraint buildForeignKeyConstraint(Vector fkFieldNames, Vector pkFieldNames, TableDefinition targetTable, DatabasePlatform platform) {
+         assert fkFieldNames.size() > 0 && fkFieldNames.size() == pkFieldNames.size();
+         
+         ForeignKeyConstraint fkConstraint = new ForeignKeyConstraint();
+         for(int i=0; i<fkFieldNames.size(); i++) {
+             fkConstraint.getSourceFields().add((String)fkFieldNames.get(i));
+             fkConstraint.getTargetFields().add((String)pkFieldNames.get(i));
+         }
+ 
+         fkConstraint.setTargetTable(targetTable.getFullName());
+         String fkFieldName = (String)fkFieldNames.get(0);
+         String name = buildForeignKeyConstraintName(this.getName(), fkFieldName, platform.getMaxForeignKeyNameSize());
+ 
+         fkConstraint.setName(name);
+         return fkConstraint;
+     }
+ 
+     /**
       * Return foreign key constraint name built from the table and field name with the specified maximum length. To
       * make the name short enough we
       * 1. Drop the "FK_" prefix.
***************
*** 500,507 ****
                  clone.addField((FieldDefinition)fieldDef.clone());
              }
          }
!         if (foreignKeys != null) {
!             clone.setForeignKeys((Vector)foreignKeys.clone());
          }
          if (uniqueKeys != null) {
              clone.setUniqueKeys((Vector)uniqueKeys.clone());
--- 523,530 ----
                  clone.addField((FieldDefinition)fieldDef.clone());
              }
          }
!         if (foreignKeyMap != null) {
!             clone.setForeignKeyMap((HashMap) foreignKeyMap.clone());
          }
          if (uniqueKeys != null) {
              clone.setUniqueKeys((Vector)uniqueKeys.clone());
***************
*** 514,529 ****
       * Execute the SQL alter table constraint creation string.
       */
      public void createConstraints(AbstractSession session, Writer schemaWriter) throws TopLinkException {       
!         if (schemaWriter == null) {
!             this.createConstraintsOnDatabase(session);
!         } else {
!             createForeignConstraints(session, schemaWriter);
!             createUniqueContraints(session, schemaWriter);            
!             
!         }
      }
  
!     private void createUniqueContraints(final AbstractSession session, final Writer schemaWriter) throws ValidationException {       
          for (Enumeration uniqueKeysEnum = getUniqueKeys().elements();
                   uniqueKeysEnum.hasMoreElements();) {              
              UniqueKeyConstraint uniqueKey = (UniqueKeyConstraint)uniqueKeysEnum.nextElement();
--- 537,552 ----
       * Execute the SQL alter table constraint creation string.
       */
      public void createConstraints(AbstractSession session, Writer schemaWriter) throws TopLinkException {       
!         createUniqueConstraints(session, schemaWriter);
!         createForeignConstraints(session, schemaWriter);
      }
  
!     void createUniqueConstraints(final AbstractSession session, final Writer schemaWriter) throws ValidationException {
!         if (schemaWriter == null) {
!             createUniqueConstraintsOnDatabase(session);
!             return;
!         }
!         
          for (Enumeration uniqueKeysEnum = getUniqueKeys().elements();
                   uniqueKeysEnum.hasMoreElements();) {              
              UniqueKeyConstraint uniqueKey = (UniqueKeyConstraint)uniqueKeysEnum.nextElement();
***************
*** 539,551 ****
          }            
      }
  
!     private void createForeignConstraints(final AbstractSession session, final Writer schemaWriter) throws ValidationException {
!         for (Enumeration foreignKeysEnum = getForeignKeys().elements();
!                  foreignKeysEnum.hasMoreElements();) {
!             ForeignKeyConstraint foreignKey = (ForeignKeyConstraint)foreignKeysEnum.nextElement();
              buildConstraintCreationWriter(session, foreignKey, schemaWriter).toString();
              try {
!                 if (createSQLFiles){                    
                      schemaWriter.write(session.getPlatform().getStoredProcedureTerminationToken());
                  }
                  schemaWriter.write("\n");
--- 562,577 ----
          }            
      }
  
!     void createForeignConstraints(final AbstractSession session, final Writer schemaWriter) throws ValidationException {
!         if (schemaWriter == null) {
!             createForeignConstraintsOnDatabase(session);
!             return;
!         }
!         
!         for (ForeignKeyConstraint foreignKey : getForeignKeyMap().values()) {
              buildConstraintCreationWriter(session, foreignKey, schemaWriter).toString();
              try {
!                 if (createSQLFiles) {
                      schemaWriter.write(session.getPlatform().getStoredProcedureTerminationToken());
                  }
                  schemaWriter.write("\n");
***************
*** 560,570 ****
       * Execute the SQL alter table constraint creation string.
       */
      public void createConstraintsOnDatabase(AbstractSession session) throws TopLinkException {
-         createForeignConstraintsOnDatabase(session);
          createUniqueConstraintsOnDatabase(session);       
      }
  
!     private void createUniqueConstraintsOnDatabase(final AbstractSession session) throws ValidationException, DatabaseException {       
          if ((!session.getPlatform().supportsUniqueKeyConstraints()) || getUniqueKeys().isEmpty()) {
              return;
          }
--- 586,596 ----
       * Execute the SQL alter table constraint creation string.
       */
      public void createConstraintsOnDatabase(AbstractSession session) throws TopLinkException {
          createUniqueConstraintsOnDatabase(session);       
+         createForeignConstraintsOnDatabase(session);
      }
  
!     void createUniqueConstraintsOnDatabase(final AbstractSession session) throws ValidationException, DatabaseException {       
          if ((!session.getPlatform().supportsUniqueKeyConstraints()) || getUniqueKeys().isEmpty()) {
              return;
          }
***************
*** 576,590 ****
          } 
      }
  
!     private void createForeignConstraintsOnDatabase(final AbstractSession session) throws ValidationException, DatabaseException {        
!         if ((!session.getPlatform().supportsForeignKeyConstraints()) || getForeignKeys().isEmpty()) {
              return;
          }
  
!         for (Enumeration foreignKeysEnum = getForeignKeys().elements();
!                  foreignKeysEnum.hasMoreElements();) {
!             ForeignKeyConstraint foreignKey = (ForeignKeyConstraint)foreignKeysEnum.nextElement();
!             session.executeNonSelectingCall(new oracle.toplink.essentials.queryframework.SQLCall(buildConstraintCreationWriter(session, foreignKey, new StringWriter()).toString()));
          }
      }
  
--- 602,614 ----
          } 
      }
  
!     void createForeignConstraintsOnDatabase(final AbstractSession session) throws ValidationException, DatabaseException {        
!         if ((!session.getPlatform().supportsForeignKeyConstraints()) || getForeignKeyMap().isEmpty()) {
              return;
          }
  
!         for (ForeignKeyConstraint foreignKey : getForeignKeyMap().values()) {
!             session.executeNonSelectingCall(new SQLCall(buildConstraintCreationWriter(session, foreignKey, new StringWriter()).toString()));
          }
      }
  
***************
*** 604,612 ****
          if (schemaWriter == null) {
              this.dropConstraintsOnDatabase(session);
          } else {
!             for (Enumeration foreignKeysEnum = getForeignKeys().elements();
!                      foreignKeysEnum.hasMoreElements();) {
!                 ForeignKeyConstraint foreignKey = (ForeignKeyConstraint)foreignKeysEnum.nextElement();
                  buildConstraintDeletionWriter(session, foreignKey, schemaWriter).toString();
                  try {
                      if (createSQLFiles) {
--- 628,634 ----
          if (schemaWriter == null) {
              this.dropConstraintsOnDatabase(session);
          } else {
!             for (ForeignKeyConstraint foreignKey : getForeignKeyMap().values()) {
                  buildConstraintDeletionWriter(session, foreignKey, schemaWriter).toString();
                  try {
                      if (createSQLFiles) {
***************
*** 660,691 ****
      }
  
      private void dropForeignConstraintsOnDatabase(final AbstractSession session) throws ValidationException {        
!         if ((!session.getPlatform().supportsForeignKeyConstraints()) || getForeignKeys().isEmpty()) {
              return;
          } 
  
!         for (Enumeration foreignKeysEnum = getForeignKeys().elements();
!                  foreignKeysEnum.hasMoreElements();) {
!             ForeignKeyConstraint foreignKey = (ForeignKeyConstraint)foreignKeysEnum.nextElement();
              try {
!                 session.executeNonSelectingCall(new oracle.toplink.essentials.queryframework.SQLCall(buildConstraintDeletionWriter(session, foreignKey, new StringWriter()).toString()));
              } catch (DatabaseException ex) {/* ignore */
              }
          }
      }
  
      public Vector getFields() {
          return fields;
      }
  
!     public Vector getForeignKeys() {
!         return foreignKeys;
      }
  
      public Vector getUniqueKeys() {
          return uniqueKeys;
      }
      
      public Vector getPrimaryKeyFieldNames() {
          Vector keyNames = new Vector();
  
--- 682,739 ----
      }
  
      private void dropForeignConstraintsOnDatabase(final AbstractSession session) throws ValidationException {        
!         if ((!session.getPlatform().supportsForeignKeyConstraints()) || getForeignKeyMap().isEmpty()) {
              return;
          } 
  
!         for (ForeignKeyConstraint foreignKey : getForeignKeyMap().values()) {
              try {
!                 session.executeNonSelectingCall(new SQLCall(buildConstraintDeletionWriter(session, foreignKey, new StringWriter()).toString()));
              } catch (DatabaseException ex) {/* ignore */
              }
          }
      }
  
+ 
+     /**
+      * INTERNAL:
+      */
+     HashMap<String, ForeignKeyConstraint> getForeignKeyMap() {
+         return foreignKeyMap;
+     }
+ 
+     /**
+      * INTERNAL:
+      */
+     void setForeignKeyMap(HashMap<String, ForeignKeyConstraint> foreignKeyMap) {
+         this.foreignKeyMap = foreignKeyMap;
+     }
+ 
+     /**
+      * PUBLIC:
+      */
      public Vector getFields() {
          return fields;
      }
  
!     /**
!      * PUBLIC:
!      * Returns the ForeignKeyConstraint list.
!      */
!     public Vector<ForeignKeyConstraint> getForeignKeys() {
!         return new Vector<ForeignKeyConstraint>(foreignKeyMap.values());
      }
  
+     /**
+      * PUBLIC:
+      */
      public Vector getUniqueKeys() {
          return uniqueKeys;
      }
      
+     /**
+      * PUBLIC:
+      */
      public Vector getPrimaryKeyFieldNames() {
          Vector keyNames = new Vector();
  
***************
*** 698,715 ****
          return keyNames;
      }
  
      public void setFields(Vector fields) {
          this.fields = fields;
      }
  
!     public void setForeignKeys(Vector foreignKeys) {
!         this.foreignKeys = foreignKeys;
      }
      
      public void setUniqueKeys(Vector uniqueKeys) {
          this.uniqueKeys = uniqueKeys;
      }
      
      public void setCreateSQLFiles(boolean genFlag) {
          this.createSQLFiles = genFlag;
      }    
--- 746,782 ----
          return keyNames;
      }
  
+     /**
+      * PUBLIC:
+      */
      public void setFields(Vector fields) {
          this.fields = fields;
      }
  
!     /**
!      * PUBLIC:
!      * Set the ForeignKeyConstraint list.
!      * If the list contains the same name foreign key constraints, only the first one of that name will be added.
!      */
!     public void setForeignKeys(Vector<ForeignKeyConstraint> foreignKeys) {
!         foreignKeyMap.clear();
!         if (foreignKeys != null) {
!             for(ForeignKeyConstraint foreignKey : foreignKeys) {
!                 foreignKeyMap.put(foreignKey .getName(), foreignKey);
!             }
!         }
      }
      
+     /**
+      * PUBLIC:
+      */
      public void setUniqueKeys(Vector uniqueKeys) {
          this.uniqueKeys = uniqueKeys;
      }
      
+     /**
+      * PUBLIC:
+      */
      public void setCreateSQLFiles(boolean genFlag) {
          this.createSQLFiles = genFlag;
      }    
================================================================================
Merge Diffs: /ade/tware_toplink10i/tldev/source/essentials/oracle/toplink/essentials/tools/schemaframework/DefaultTableGenerator.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1072_table_generation_wonsoek_kim_061107/ade_storage/000003/AB0952363AC40CBFE034080020E8C54E.13
Report generated at Tue Nov  7 10:57:21 2006
--------------------------------------------------------------------------------
*** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1072_table_generation_wonsoek_kim_061107/ade_storage/000003/AB0952363AC40CBFE034080020E8C54E.13	Mon Nov  6 14:28:29 2006
--- /ade/tware_toplink10i/tldev/source/essentials/oracle/toplink/essentials/tools/schemaframework/DefaultTableGenerator.java	Tue Nov  7 10:57:21 2006
***************
*** 24,30 ****
  import java.sql.ResultSet;
  import java.sql.SQLException;
  import java.util.HashMap;
- import java.util.Hashtable;
  import java.util.Iterator;
  import java.util.Map;
  import java.util.Vector;
--- 24,29 ----
***************
*** 45,50 ****
--- 44,50 ----
  
  import oracle.toplink.essentials.descriptors.ClassDescriptor;
  import oracle.toplink.essentials.internal.sessions.AbstractSession;
+ import oracle.toplink.essentials.internal.databaseaccess.DatabasePlatform;
  import oracle.toplink.essentials.mappings.OneToManyMapping;
  import oracle.toplink.essentials.mappings.OneToOneMapping;
  import oracle.toplink.essentials.sessions.Project;
***************
*** 93,98 ****
--- 93,101 ----
      //the project object used to generate the default data schema.
      Project project = null;
  
+     //the target database platform
+     private DatabasePlatform databasePlatform;
+     
      //used to track the table definition: keyed by the table name, and valued
      //by the table definition object
      private Map tableMap = null;
***************
*** 106,111 ****
--- 109,115 ----
       */
      public DefaultTableGenerator(Project project) {
          this.project = project;
+         databasePlatform = project.getLogin().getPlatform();
          tableMap = new HashMap();
          fieldMap = new HashMap();
      }
***************
*** 124,130 ****
  
              //aggregate RelationalDescriptor does not contains table/field data
              if (!desc.isAggregateDescriptor()) {
!                 initTableSchema((ClassDescriptor)desc);
              }
          }
  
--- 128,134 ----
  
              //aggregate RelationalDescriptor does not contains table/field data
              if (!desc.isAggregateDescriptor()) {
!                 initTableSchema(desc);
              }
          }
  
***************
*** 297,332 ****
          //first create relation table
          TableDefinition tblDef = getTableDefFromDBTable(mapping.getRelationTable());
  
-         DatabaseField dbField = null;
-         DatabaseField parentDBField = null;
-         FieldDefinition fldDef = null;
- 
          //add source foreign key fields into the relation table
          Vector srcFkFields = mapping.getSourceRelationKeyFields();
  
!         for (int index = 0; index < srcFkFields.size(); index++) {
!             parentDBField = (DatabaseField) mapping.getSourceKeyFields().get(index);
!             dbField = resolveDatabaseField((DatabaseField) srcFkFields.get(index), parentDBField);
!             setFieldToRelationTable(dbField, tblDef);
!             setForeignKeyForRelationTable(dbField, parentDBField);
!         }
  
          //add target foreign key fields into the relation table
          Vector targFkFields = mapping.getTargetRelationKeyFields();
! 
!         for (int index = 0; index < targFkFields.size(); index++) {
!             parentDBField = (DatabaseField) mapping.getTargetKeyFields().get(index);
!             dbField = resolveDatabaseField((DatabaseField) targFkFields.get(index), parentDBField);
!             setFieldToRelationTable(dbField, tblDef);
!             setForeignKeyForRelationTable(dbField, parentDBField);
!         }
      }
  
!     private void setForeignKeyForRelationTable(final DatabaseField dbField, final DatabaseField parentDBField) {
!         FieldDefinition fldDef;
!         fldDef = getFieldDefFromDBField(dbField, false);
!         fldDef.setForeignKeyFieldName(parentDBField.getTable().getName() + "." + parentDBField.getName());
!         return;
      }
  
      /**
--- 301,345 ----
          //first create relation table
          TableDefinition tblDef = getTableDefFromDBTable(mapping.getRelationTable());
  
          //add source foreign key fields into the relation table
          Vector srcFkFields = mapping.getSourceRelationKeyFields();
+         Vector srcKeyFields = mapping.getSourceKeyFields();
  
!         buildRelationTableFields(tblDef, srcFkFields, srcKeyFields);
  
          //add target foreign key fields into the relation table
          Vector targFkFields = mapping.getTargetRelationKeyFields();
!         Vector targKeyFields = mapping.getTargetKeyFields();
!         
!         buildRelationTableFields(tblDef, targFkFields, targKeyFields);
      }
  
!     /**
!      * Build field definitions and foreign key constraints for all many-to-many relation table.
!      */
!     private void buildRelationTableFields(TableDefinition tblDef, Vector fkFields, Vector targetFields) {
!         assert fkFields.size() > 0 && fkFields.size() == targetFields.size();
!         
!         DatabaseField fkField = null;
!         DatabaseField targetField = null;
!         Vector<String> fkFieldNames = new Vector();
!         Vector<String> targetFieldNames = new Vector();
! 
!         for (int index = 0; index < fkFields.size(); index++) {
!             fkField = (DatabaseField) fkFields.get(index);
!             targetField = (DatabaseField) targetFields.get(index);
!             fkFieldNames.add(fkField.getName());
!             targetFieldNames.add(targetField.getName());
!             
!             fkField = resolveDatabaseField(fkField, targetField);
!             setFieldToRelationTable(fkField, tblDef);
!         }
!         
!         // add a foreign key constraint
!         DatabaseTable targetTable = targetField.getTable();
!         TableDefinition targetTblDef = getTableDefFromDBTable(targetTable);
!         
!         addForeignKeyConstraint(tblDef, targetTblDef, fkFieldNames, targetFieldNames);
      }
  
      /**
***************
*** 390,415 ****
      }    
  
      private void addForeignKeyFieldToFieldDefinition(final Map srcFields) {
          DatabaseField dbSrcField = null;
          DatabaseField dbTrgField = null;
          
          //add source foreign key fields into the table
          for (Iterator srcFkFields = srcFields.keySet().iterator(); srcFkFields.hasNext();) {            
              dbSrcField = (DatabaseField)srcFkFields.next();
              dbTrgField = (DatabaseField)srcFields.get(dbSrcField);
              
              FieldDefinition srcFldDef = (FieldDefinition)fieldMap.get(dbSrcField);
              FieldDefinition trgFldDef = (FieldDefinition)fieldMap.get(dbTrgField);
              
!             srcFldDef.setForeignKeyFieldName(
!                 dbTrgField.getTable().getQualifiedName() + "." + dbTrgField.getName());
!             
!             // Also ensure that the type, size and subsize of the foreign key field is 
!             // same as that of the original field.
!             srcFldDef.setType(trgFldDef.getType());
!             srcFldDef.setSize(trgFldDef.getSize()); 
!             srcFldDef.setSubSize(trgFldDef.getSubSize());            
          }        
      }
  
      /**
--- 403,443 ----
      }    
  
      private void addForeignKeyFieldToFieldDefinition(final Map srcFields) {
+         if(srcFields.size() == 0) {
+             return;
+         }
+         
          DatabaseField dbSrcField = null;
          DatabaseField dbTrgField = null;
          
          //add source foreign key fields into the table
+         Vector<String> fkFieldNames = new Vector();
+         Vector<String> targetFieldNames = new Vector();
          for (Iterator srcFkFields = srcFields.keySet().iterator(); srcFkFields.hasNext();) {            
              dbSrcField = (DatabaseField)srcFkFields.next();
              dbTrgField = (DatabaseField)srcFields.get(dbSrcField);
+             fkFieldNames.add(dbSrcField.getName());
+             targetFieldNames.add(dbTrgField.getName());
              
              FieldDefinition srcFldDef = (FieldDefinition)fieldMap.get(dbSrcField);
              FieldDefinition trgFldDef = (FieldDefinition)fieldMap.get(dbTrgField);
              
!             if(srcFldDef != null && trgFldDef != null) {
!                 // Also ensure that the type, size and subsize of the foreign key field is 
!                 // same as that of the original field.
!                 srcFldDef.setType(trgFldDef.getType());
!                 srcFldDef.setSize(trgFldDef.getSize()); 
!                 srcFldDef.setSubSize(trgFldDef.getSubSize());
!             }
          }        
+ 
+         // add a foreign key constraint
+         DatabaseTable sourceTable = dbSrcField.getTable();
+         DatabaseTable targetTable = dbTrgField.getTable();
+         TableDefinition sourceTableDef = getTableDefFromDBTable(sourceTable);
+         TableDefinition targetTableDef = getTableDefFromDBTable(targetTable);
+         
+         addForeignKeyConstraint(sourceTableDef, targetTableDef, fkFieldNames, targetFieldNames);
      }
  
      /**
***************
*** 439,444 ****
--- 467,475 ----
          DatabaseField reslovedDatabaseField = new DatabaseField();
          reslovedDatabaseField.setName(childField.getName());
          reslovedDatabaseField.setType(getFieldDefFromDBField(parentField, true).getType());
+         //Table should be set, otherwise other same name field will be used wrongly because equals() is true.
+         //Fix for GF#1392 the same name column for the entity and many-to-many table cause wrong pk constraint.
+         reslovedDatabaseField.setTable(childField.getTable());
  
          return reslovedDatabaseField;
      }
***************
*** 478,484 ****
                  }
  
                  if ((fieldType == null) || (!fieldType.isPrimitive() && 
!                         (new DatabaseSessionImpl(project).getPlatform().getFieldTypeDefinition(fieldType) == null))) {
                      //TODO: log a warning for inaccessiable type or not convertable type.
                      AbstractSessionLog.getLog().log(SessionLog.FINEST, "field_type_set_to_java_lang_string", dbField.getQualifiedName(), fieldType);
  
--- 509,515 ----
                  }
  
                  if ((fieldType == null) || (!fieldType.isPrimitive() && 
!                         (databasePlatform.getFieldTypeDefinition(fieldType) == null))) {
                      //TODO: log a warning for inaccessiable type or not convertable type.
                      AbstractSessionLog.getLog().log(SessionLog.FINEST, "field_type_set_to_java_lang_string", dbField.getQualifiedName(), fieldType);
  
***************
*** 531,553 ****
              dbTbl = (DatabaseTable) dbTblIter.next();
              Map srcFields = (HashMap)desc.getAdditionalTablePrimaryKeyFields().get(dbTbl);
              if (null != srcFields) {
!                 addJoinColumnsFkFieldToFieldDefinition(srcFields);
              }
          }              
      }    
     
!     private void addJoinColumnsFkFieldToFieldDefinition(final Map srcFields) {
!         DatabaseField dbSrcField = null;
!         DatabaseField dbTrgField = null;
          
          //add source foreign key fields into the table
!         for (Iterator srcFkFields = srcFields.keySet().iterator(); srcFkFields.hasNext();) {            
!             dbSrcField = (DatabaseField)srcFkFields.next();
!             dbTrgField = (DatabaseField)srcFields.get(dbSrcField);            
!             FieldDefinition srcFldDef = (FieldDefinition)fieldMap.get(dbSrcField);
!             FieldDefinition trgFldDef = (FieldDefinition)fieldMap.get(dbTrgField);            
!             trgFldDef.setForeignKeyFieldName(
!                 dbSrcField.getTable().getQualifiedName() + "." + dbSrcField.getName());
!         }        
      }
  }
--- 562,688 ----
              dbTbl = (DatabaseTable) dbTblIter.next();
              Map srcFields = (HashMap)desc.getAdditionalTablePrimaryKeyFields().get(dbTbl);
              if (null != srcFields) {
!                 addJoinColumnsFkConstraint(srcFields);
              }
          }              
      }    
     
!     private void addJoinColumnsFkConstraint(final Map srcFields) {
!         if(srcFields.size() == 0) {
!             return;
!         }
!         
!         DatabaseField fkField = null;
!         DatabaseField pkField = null;
!         Vector<String> fkFieldNames = new Vector();
!         Vector<String> pkFieldNames = new Vector();
          
          //add source foreign key fields into the table
!         for (Iterator srcPkFields = srcFields.keySet().iterator(); srcPkFields.hasNext();) {            
!             pkField = (DatabaseField)srcPkFields.next();
!             fkField = (DatabaseField)srcFields.get(pkField);
!             fkFieldNames.add(fkField.getName());
!             pkFieldNames.add(pkField.getName());
!         }
! 
!         // add a foreign key constraint
!         DatabaseTable sourceTable = fkField.getTable();
!         DatabaseTable targetTable = pkField.getTable();
!         TableDefinition sourceTableDef = getTableDefFromDBTable(sourceTable);
!         TableDefinition targetTableDef = getTableDefFromDBTable(targetTable);
!         
!         addForeignKeyConstraint(sourceTableDef, targetTableDef, fkFieldNames, pkFieldNames);
!     }
! 
!     /**
!      * Add a foreign key constraint to the source table.
!      */
!     private void addForeignKeyConstraint(TableDefinition sourceTableDef, TableDefinition targetTableDef, 
!                                          Vector<String> fkFields, Vector<String> targetFields) {
!         assert fkFields.size() > 0 && fkFields.size() == targetFields.size();
!         
!         // target keys could be primary keys or candidate(unique) keys of the target table
! 
!         Vector<String> fkFieldNames = fkFields;
!         Vector<String> targetFieldNames = targetFields;
!         
!         if (fkFields.size() > 1) {
!             // if composite key, we should consider the order of keys.
!             // Foreign Key constraint should follow the primary/unique key order of the target table.
!             // e.g. if the primary key constraint of the target table is (p2, p1),
!             // foreign key constraint should be "(f2, f1) REFERENCES TARGET (p2, p1)".
! 
!             // we try to reorder keys using primary keys or unique keys order of the target table,
!             // but if we might not resolve it due to incorrect field name, then let it as it is.
!             // This will trigger underlying database exception so users can recognize errors.
!             
!             boolean resolved = false;
!             boolean error = false;
!             
!             Map<String, String> targetToFkField = new HashMap<String, String>();
!             for (int index = 0; index < fkFields.size(); index++) {
!                 String targetField = targetFields.get(index);
!                 if (targetToFkField.containsKey(targetField)) {
!                     //target key column appears more than once
!                     error = true;
!                     break;
!                 }
!                 targetToFkField.put(targetField, fkFields.get(index));
!             }
! 
!             Vector<String> orderedFkFields = new Vector<String>(fkFields.size());
!             Vector<String> orderedTargetFields = new Vector<String>(targetFields.size());
! 
!             if (!error) {
!                 // if target fields are primary keys
!                 resolved = true;
!                 for (String pkField : (Vector<String>)targetTableDef.getPrimaryKeyFieldNames()) {
!                     String fkField = targetToFkField.get(pkField);
!                     if (fkField == null) {
!                         //primary key column not found
!                         resolved = false;
!                         break;
!                     }
!                     orderedFkFields.add(fkField);
!                     orderedTargetFields.add(pkField);
!                 }
!             }
!             
!             if (!error && !resolved) {
!                 // if target fields are unique keys
!                 for (Object uniqueConstraint : targetTableDef.getUniqueKeys()) {
!                     orderedFkFields.setSize(0);
!                     orderedTargetFields.setSize(0);
! 
!                     resolved = true;
!                     for (String ukField : (String[])uniqueConstraint) {
!                         String fkField = targetToFkField.get(ukField);
!                         if (fkField == null) {
!                             //unique key column not found
!                             resolved = false;
!                             break;
!                         }
!                         orderedFkFields.add(fkField);
!                         orderedTargetFields.add(ukField);
!                     }
!                     if (resolved) {
!                         break;
!                     }
!                 }
!             }
! 
!             if (resolved) {
!                 fkFieldNames = orderedFkFields;
!                 targetFieldNames = orderedTargetFields;
!             }
!         }
! 
!         // For bidirectional relationships both side of mapping will make the same FK constraint twice.
!         // TableDefinition.addForeignKeyConstraint() will ignore the same FK constraint.
! 
!         ForeignKeyConstraint fkc = sourceTableDef.buildForeignKeyConstraint(fkFieldNames, targetFieldNames,
!             targetTableDef, databasePlatform);
!         sourceTableDef.addForeignKeyConstraint(fkc);
      }
+     
  }
================================================================================
Merge Diffs: /ade/tware_toplink10i/tldev/source/essentials/oracle/toplink/essentials/tools/schemaframework/FieldDefinition.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1072_table_generation_wonsoek_kim_061107/ade_storage/000004/AB0952363AC40CBFE034080020E8C54E.7
Report generated at Tue Nov  7 10:57:21 2006
--------------------------------------------------------------------------------
*** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1072_table_generation_wonsoek_kim_061107/ade_storage/000004/AB0952363AC40CBFE034080020E8C54E.7	Mon Nov  6 14:28:29 2006
--- /ade/tware_toplink10i/tldev/source/essentials/oracle/toplink/essentials/tools/schemaframework/FieldDefinition.java	Tue Nov  7 10:57:21 2006
***************
*** 18,24 ****
   * own identifying information: Portions Copyright [yyyy] 
   * [name of copyright owner]
   */
! // Copyright (c) 1998, 2005, Oracle. All rights reserved.  
  package oracle.toplink.essentials.tools.schemaframework;
  
  import java.io.*;
--- 18,24 ----
   * own identifying information: Portions Copyright [yyyy] 
   * [name of copyright owner]
   */
! // Copyright (c) 1998, 2006, Oracle. All rights reserved.  
  package oracle.toplink.essentials.tools.schemaframework;
  
  import java.io.*;
***************
*** 50,56 ****
      protected boolean isUnique;
      protected String additional;
      protected String constraint;
!     protected String foreignKeyFieldName;
  
      public FieldDefinition() {
          this.name = "";
--- 50,57 ----
      protected boolean isUnique;
      protected String additional;
      protected String constraint;
!     // @deprecated Use ForeignKeyConstraint instead.
!     protected String foreignKeyFieldName; //fully-qualified foreign key field name
  
      public FieldDefinition() {
          this.name = "";
***************
*** 205,210 ****
--- 206,216 ----
          return constraint;
      }
  
+     /**
+      * PUBLIC:
+      * Return fully-qualified foreign key field name.
+      * @deprecated Use ForeignKeyConstraint instead.
+      */
      public String getForeignKeyFieldName() {
          return foreignKeyFieldName;
      }
***************
*** 296,301 ****
--- 302,314 ----
          constraint = string;
      }
  
+     /**
+      * PUBLIC:
+      * Set the foreign key field name. This value is used for a foreign key constraint.
+      * 
+      * @param foreignKeyFieldName fully-qualified field name
+      * @deprecated Use ForeignKeyConstraint instead.
+      */
      public void setForeignKeyFieldName(String foreignKeyFieldName) {
          this.foreignKeyFieldName = foreignKeyFieldName;
      }
================================================================================
Merge Diffs: /ade/tware_toplink10i/tldev/source/essentials/oracle/toplink/essentials/tools/schemaframework/ForeignKeyConstraint.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1072_table_generation_wonsoek_kim_061107/ade_storage/000005/AB0952363AC40CBFE034080020E8C54E.5
Report generated at Tue Nov  7 10:57:21 2006
--------------------------------------------------------------------------------
*** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1072_table_generation_wonsoek_kim_061107/ade_storage/000005/AB0952363AC40CBFE034080020E8C54E.5	Mon Nov  6 14:28:29 2006
--- /ade/tware_toplink10i/tldev/source/essentials/oracle/toplink/essentials/tools/schemaframework/ForeignKeyConstraint.java	Tue Nov  7 10:57:21 2006
***************
*** 18,24 ****
   * own identifying information: Portions Copyright [yyyy] 
   * [name of copyright owner]
   */
! // Copyright (c) 1998, 2005, Oracle. All rights reserved.  
  package oracle.toplink.essentials.tools.schemaframework;
  
  import java.io.*;
--- 18,24 ----
   * own identifying information: Portions Copyright [yyyy] 
   * [name of copyright owner]
   */
! // Copyright (c) 1998, 2006, Oracle. All rights reserved.  
  package oracle.toplink.essentials.tools.schemaframework;
  
  import java.io.*;
***************
*** 33,41 ****
   */
  public class ForeignKeyConstraint implements Serializable {
      protected String name;
!     protected Vector sourceFields;
!     protected Vector targetFields;
!     protected String targetTable;
      protected boolean shouldCascadeOnDelete;
  
      public ForeignKeyConstraint() {
--- 33,41 ----
   */
  public class ForeignKeyConstraint implements Serializable {
      protected String name;
!     protected Vector sourceFields; //source(foreign key) field names
!     protected Vector targetFields; //target(primary key) field names
!     protected String targetTable; //fully-qualified target table name
      protected boolean shouldCascadeOnDelete;
  
      public ForeignKeyConstraint() {
================================================================================
Merge Diffs: /ade/tware_toplink10i/tldev/source/essentials/oracle/toplink/essentials/tools/schemaframework/SchemaManager.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1072_table_generation_wonsoek_kim_061107/ade_storage/000006/AB0952363AC40CBFE034080020E8C54E.14
Report generated at Tue Nov  7 10:57:21 2006
--------------------------------------------------------------------------------
*** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1072_table_generation_wonsoek_kim_061107/ade_storage/000006/AB0952363AC40CBFE034080020E8C54E.14	Mon Nov  6 14:28:29 2006
--- /ade/tware_toplink10i/tldev/source/essentials/oracle/toplink/essentials/tools/schemaframework/SchemaManager.java	Tue Nov  7 10:57:21 2006
***************
*** 19,25 ****
   * [name of copyright owner]
   */
  
! // Copyright (c) 1998, 2006, Oracle. All rights reserved.  
  package oracle.toplink.essentials.tools.schemaframework;
  
  import java.io.Writer;
--- 19,25 ----
   * [name of copyright owner]
   */
  
! // Copyright (c) 1998, 2006, Oracle. All rights reserved.  
  package oracle.toplink.essentials.tools.schemaframework;
  
  import java.io.Writer;
***************
*** 55,61 ****
      protected DatabaseSessionImpl session;
      protected Writer createSchemaWriter;
      protected Writer dropSchemaWriter;
!     protected boolean createSQLFiles = true;
  
      public SchemaManager(DatabaseSessionImpl session) {
          this.session = session;
--- 55,61 ----
      protected DatabaseSessionImpl session;
      protected Writer createSchemaWriter;
      protected Writer dropSchemaWriter;
!     protected boolean createSQLFiles = true; //if true, schema writer will add terminator string.
  
      public SchemaManager(DatabaseSessionImpl session) {
          this.session = session;
***************
*** 112,120 ****
       */
      public void closeDDLWriter() {
          closeDDLWriter(createSchemaWriter);
!         if (null != dropSchemaWriter) {
!             closeDDLWriter(dropSchemaWriter);
!         }
      }
  
      public void closeDDLWriter(Writer schemaWriter) {
--- 112,120 ----
       */
      public void closeDDLWriter() {
          closeDDLWriter(createSchemaWriter);
!         closeDDLWriter(dropSchemaWriter);
!         createSchemaWriter = null;
!         dropSchemaWriter = null;
      }
  
      public void closeDDLWriter(Writer schemaWriter) {
***************
*** 125,131 ****
          try {
              schemaWriter.flush();
              schemaWriter.close();
-             schemaWriter = null;
          } catch (java.io.IOException ioException) {
              throw ValidationException.fileError(ioException);
          }
--- 125,130 ----
***************
*** 143,148 ****
--- 142,165 ----
              tableDefinition.createConstraints(getSession(), createSchemaWriter);
          }
      }
+     
+     void createUniqueConstraints(TableDefinition tableDefinition) throws TopLinkException {
+         if (shouldWriteToDatabase()) {
+             tableDefinition.createUniqueConstraintsOnDatabase(getSession());
+         } else {
+             tableDefinition.setCreateSQLFiles(createSQLFiles);
+             tableDefinition.createUniqueConstraints(getSession(), createSchemaWriter);
+         }
+     }
+     
+     void createForeignConstraints(TableDefinition tableDefinition) throws TopLinkException {
+         if (shouldWriteToDatabase()) {
+             tableDefinition.createForeignConstraintsOnDatabase(getSession());
+         } else {
+             tableDefinition.setCreateSQLFiles(createSQLFiles);
+             tableDefinition.createForeignConstraints(getSession(), createSchemaWriter);
+         }
+     }
  
      /**
       * Use the definition object to create the schema entity on the database.
================================================================================
Merge Diffs: /ade/tware_toplink10i/tldev/source/essentials/oracle/toplink/essentials/tools/schemaframework/TableCreator.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1072_table_generation_wonsoek_kim_061107/ade_storage/000007/AB0952363AC40CBFE034080020E8C54E.5
Report generated at Tue Nov  7 10:57:21 2006
--------------------------------------------------------------------------------
*** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1072_table_generation_wonsoek_kim_061107/ade_storage/000007/AB0952363AC40CBFE034080020E8C54E.5	Mon Nov  6 14:28:29 2006
--- /ade/tware_toplink10i/tldev/source/essentials/oracle/toplink/essentials/tools/schemaframework/TableCreator.java	Tue Nov  7 10:57:21 2006
***************
*** 18,24 ****
   * own identifying information: Portions Copyright [yyyy] 
   * [name of copyright owner]
   */
! // Copyright (c) 1998, 2005, Oracle. All rights reserved.  
  package oracle.toplink.essentials.tools.schemaframework;
  
  import java.util.*;
--- 18,24 ----
   * own identifying information: Portions Copyright [yyyy] 
   * [name of copyright owner]
   */
! // Copyright (c) 1998, 2006, Oracle. All rights reserved.  
  package oracle.toplink.essentials.tools.schemaframework;
  
  import java.util.*;
***************
*** 75,82 ****
              schemaManager.buildFieldTypes((TableDefinition)enumtr.nextElement());
          }
  
          for (Enumeration enumtr = getTableDefinitions().elements(); enumtr.hasMoreElements();) {
!             schemaManager.createConstraints((TableDefinition)enumtr.nextElement());
          }
      }
  
--- 75,88 ----
              schemaManager.buildFieldTypes((TableDefinition)enumtr.nextElement());
          }
  
+         // Unique constraints should be generated before foreign key constraints,
+         // because foreign key constraints can reference unique constraints
          for (Enumeration enumtr = getTableDefinitions().elements(); enumtr.hasMoreElements();) {
!             schemaManager.createUniqueConstraints((TableDefinition)enumtr.nextElement());
!         }
!         
!         for (Enumeration enumtr = getTableDefinitions().elements(); enumtr.hasMoreElements();) {
!             schemaManager.createForeignConstraints((TableDefinition)enumtr.nextElement());
          }
      }
  
***************
*** 107,114 ****
              }
          }
  
          for (Enumeration enumtr = getTableDefinitions().elements(); enumtr.hasMoreElements();) {
!             schemaManager.createConstraints((TableDefinition)enumtr.nextElement());
          }
  
          schemaManager.createSequences();
--- 113,126 ----
              }
          }
  
+         // Unique constraints should be generated before foreign key constraints,
+         // because foreign key constraints can reference unique constraints
          for (Enumeration enumtr = getTableDefinitions().elements(); enumtr.hasMoreElements();) {
!             schemaManager.createUniqueConstraints((TableDefinition)enumtr.nextElement());
!         }
!         
!         for (Enumeration enumtr = getTableDefinitions().elements(); enumtr.hasMoreElements();) {
!             schemaManager.createForeignConstraints((TableDefinition)enumtr.nextElement());
          }
  
          schemaManager.createSequences();
***************
*** 252,259 ****
              }
          }
  
          for (Enumeration enumtr = getTableDefinitions().elements(); enumtr.hasMoreElements();) {
!             schemaManager.createConstraints((TableDefinition)enumtr.nextElement());
          }
      }
  
--- 264,277 ----
              }
          }
  
+         // Unique constraints should be generated before foreign key constraints,
+         // because foreign key constraints can reference unique constraints
+         for (Enumeration enumtr = getTableDefinitions().elements(); enumtr.hasMoreElements();) {
+             schemaManager.createUniqueConstraints((TableDefinition)enumtr.nextElement());
+         }
+         
          for (Enumeration enumtr = getTableDefinitions().elements(); enumtr.hasMoreElements();) {
!             schemaManager.createForeignConstraints((TableDefinition)enumtr.nextElement());
          }
      }
  
================================================================================
Merge Diffs: /ade/tware_toplink10i/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/tests/cmp3/ddlgeneration/DDLGenerationJUnitTestSuite.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1072_table_generation_wonsoek_kim_061107/ade_storage/000010/AB0952363AC40CBFE034080020E8C54E.0
Report generated at Tue Nov  7 10:57:21 2006
--------------------------------------------------------------------------------
*** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1072_table_generation_wonsoek_kim_061107/ade_storage/000010/AB0952363AC40CBFE034080020E8C54E.0	Tue Nov  7 10:55:25 2006
--- /ade/tware_toplink10i/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/tests/cmp3/ddlgeneration/DDLGenerationJUnitTestSuite.java	Tue Nov  7 10:55:25 2006
***************
*** 0 ****
--- 1,150 ----
+ package oracle.toplink.essentials.testing.tests.cmp3.ddlgeneration;
+ 
+ import junit.extensions.TestSetup;
+ import junit.framework.Test;
+ import junit.framework.TestSuite;
+ import oracle.toplink.essentials.testing.framework.junit.JUnitTestCase;
+ import oracle.toplink.essentials.testing.models.cmp3.ddlgeneration.CKeyEntityA;
+ import oracle.toplink.essentials.testing.models.cmp3.ddlgeneration.CKeyEntityAPK;
+ import oracle.toplink.essentials.testing.models.cmp3.ddlgeneration.CKeyEntityB;
+ import oracle.toplink.essentials.testing.models.cmp3.ddlgeneration.CKeyEntityBPK;
+ import oracle.toplink.essentials.testing.models.cmp3.ddlgeneration.CKeyEntityC;
+ import oracle.toplink.essentials.testing.models.cmp3.ddlgeneration.CKeyEntityCPK;
+ 
+ import javax.persistence.EntityManager;
+ import java.util.HashMap;
+ import java.util.Map;
+ 
+ /**
+  * JUnit test case(s) for DDL generation.
+  */
+ public class DDLGenerationJUnitTestSuite extends JUnitTestCase {
+ 
+     public DDLGenerationJUnitTestSuite() {
+         super();
+     }
+ 
+     public DDLGenerationJUnitTestSuite(String name) {
+         super(name);
+     }
+ 
+     public static Test suite() {
+         TestSuite suite = new TestSuite(DDLGenerationJUnitTestSuite.class);
+ 
+         return new TestSetup(suite) {
+ 
+             protected void setUp() {
+                 // Trigger DDL generation
+                 //TODO: Let's add a flag which do not disregard DDL generation errors.
+                 //TODO: This is required to ensure that DDL generation has succeeded.
+                 EntityManager em = createEntityManager("ddlGeneration");
+                 em.close();
+             }
+ 
+             protected void tearDown() {
+                 clearCache("ddlGeneration");
+             }
+         };
+     }
+ 
+     // Test for GF#1392
+     // If there is a same name column for the entity and many-to-many table, wrong pk constraint generated.
+     public void testDDLPkConstraintErrorIncludingRelationTableColumnName() {
+         EntityManager em = createEntityManager("ddlGeneration");
+         em.getTransaction().begin();
+         try {
+ 
+             CKeyEntityC c = new CKeyEntityC(new CKeyEntityCPK("Manager"));
+             em.persist(c);
+ 
+             em.getTransaction().commit();
+         } catch (RuntimeException e) {
+             if (em.getTransaction().isActive())
+                 em.getTransaction().rollback();
+             fail("DDL generation may generate wrong Primary Key constraint, thrown:" + e);
+         } finally {
+             em.close();
+         }
+     }
+ 
+     // Test for relationships using candidate(unique) keys
+     public void testDDLUniqueKeysAsJoinColumns() {
+         CKeyEntityAPK aKey;
+         CKeyEntityBPK bKey;
+         
+         EntityManager em = createEntityManager("ddlGeneration");
+         em.getTransaction().begin();
+         try {
+             CKeyEntityA a = new CKeyEntityA("Wonseok", "Kim");
+             CKeyEntityB b = new CKeyEntityB("B1209");
+             //set unique keys
+             b.setUnq1("u0001");
+             b.setUnq2("u0002");
+ 
+             a.setUniqueB(b);
+             b.setUniqueA(a);
+             
+             em.persist(a);
+             em.persist(b);
+ 
+             em.getTransaction().commit();
+             
+             aKey = a.getKey();
+             bKey = b.getKey();
+         } catch (RuntimeException e) {
+             if (em.getTransaction().isActive())
+                 em.getTransaction().rollback();
+             throw e;
+         } finally {
+             em.close();
+         }
+         //clearCache("ddlGeneration");
+ 
+         em = createEntityManager("ddlGeneration");
+         em.getTransaction().begin();
+         try {
+             CKeyEntityA a = em.find(CKeyEntityA.class, aKey);
+             assertNotNull(a);
+ 
+             CKeyEntityB b = a.getUniqueB();
+             assertNotNull(b);
+ 
+             assertEquals(b.getUnq1(), "u0001");
+             assertEquals(b.getUnq2(), "u0002");
+ 
+             em.getTransaction().commit();
+         } catch (RuntimeException e) {
+             if (em.getTransaction().isActive())
+                 em.getTransaction().rollback();
+             throw e;
+         } finally {
+             em.close();
+         }
+         //clearCache("ddlGeneration");
+ 
+         em = createEntityManager("ddlGeneration");
+         em.getTransaction().begin();
+         try {
+ 
+             CKeyEntityB b = em.find(CKeyEntityB.class, bKey);
+             assertNotNull(b);
+ 
+             CKeyEntityA a = b.getUniqueA();
+             assertNotNull(a);
+             assertEquals(a.getKey(), aKey);
+ 
+             em.getTransaction().commit();
+         } catch (RuntimeException e) {
+             if (em.getTransaction().isActive())
+                 em.getTransaction().rollback();
+             throw e;
+         } finally {
+             em.close();
+         }
+ 
+     }
+ 
+     public static void main(String[] args) {
+         junit.textui.TestRunner.run(suite());
+     }
+ }
================================================================================
Merge Diffs: /ade/tware_toplink10i/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/models/cmp3/ddlgeneration/CKeyEntityA.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1072_table_generation_wonsoek_kim_061107/ade_storage/000013/AB0952363AC40CBFE034080020E8C54E.0
Report generated at Tue Nov  7 10:57:21 2006
--------------------------------------------------------------------------------
*** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1072_table_generation_wonsoek_kim_061107/ade_storage/000013/AB0952363AC40CBFE034080020E8C54E.0	Tue Nov  7 10:55:29 2006
--- /ade/tware_toplink10i/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/models/cmp3/ddlgeneration/CKeyEntityA.java	Tue Nov  7 10:55:28 2006
***************
*** 0 ****
--- 1,114 ----
+ package oracle.toplink.essentials.testing.models.cmp3.ddlgeneration;
+ 
+ import javax.persistence.Column;
+ import javax.persistence.Entity;
+ import javax.persistence.GeneratedValue;
+ import static javax.persistence.GenerationType.TABLE;
+ import javax.persistence.Id;
+ import javax.persistence.IdClass;
+ import javax.persistence.JoinColumn;
+ import javax.persistence.JoinColumns;
+ import javax.persistence.ManyToOne;
+ import javax.persistence.OneToOne;
+ import javax.persistence.Table;
+ import javax.persistence.TableGenerator;
+ import java.util.Collection;
+ 
+ /**
+  * Composite key Entity.
+  * 
+  * @author Wonseok Kim
+  */
+ @Entity
+ @IdClass(CKeyEntityAPK.class)
+ @Table(name = "DDL_CKENTA")
+ @TableGenerator(
+     name = "CKEYENTITY_TABLE_GENERATOR",
+     table = "DDL_CKENT_SEQ",
+     pkColumnName = "SEQ_NAME",
+     valueColumnName = "SEQ_COUNT",
+     pkColumnValue = "CKENT_SEQ"
+ )
+ public class CKeyEntityA {
+     @Id
+     @GeneratedValue(strategy = TABLE, generator = "CKEYENTITY_TABLE_GENERATOR")
+     @Column(name = "SEQ")
+     private int seq;
+ 
+     @Id
+     @Column(name = "F_NAME")
+     private String firstName;
+ 
+     @Id
+     @Column(name = "L_NAME")
+     private String lastName;
+ 
+     @ManyToOne
+     @JoinColumns({
+         @JoinColumn(name="B_SEQ", referencedColumnName = "SEQ"),
+         @JoinColumn(name="B_CODE", referencedColumnName = "CODE")
+     })
+     private Collection<CKeyEntityB> bs;
+     
+     @OneToOne(mappedBy="a")
+     private CKeyEntityC c;
+     
+     // Relationship using candidate(unique) keys
+     // For testing whether a generated FK constraint has reordered unique keys according to target table.
+     // CKeyEntityB has unique constraint ("UNQ2", "UNQ1").
+     @OneToOne
+     @JoinColumns({
+         @JoinColumn(name="B_UNQ1", referencedColumnName = "UNQ1"),
+         @JoinColumn(name="B_UNQ2", referencedColumnName = "UNQ2")
+     })
+     private CKeyEntityB uniqueB;
+     
+ 
+     public CKeyEntityA() {
+     }
+ 
+     public CKeyEntityA(String firstName, String lastName) {
+         this.firstName = firstName;
+         this.lastName = lastName;
+     }
+ 
+     public int getSeq() {
+         return seq;
+     }
+ 
+     public String getFirstName() {
+         return firstName;
+     }
+ 
+     public String getLastName() {
+         return lastName;
+     }
+ 
+     public CKeyEntityAPK getKey() {
+         return new CKeyEntityAPK(seq, firstName, lastName);
+     }
+     
+     public Collection<CKeyEntityB> getBs() {
+         return bs;
+     }
+ 
+     public void setBs(Collection<CKeyEntityB> bs) {
+         this.bs = bs;
+     }
+ 
+     public CKeyEntityC getC() {
+         return c;
+     }
+ 
+     public void setC(CKeyEntityC c) {
+         this.c = c;
+     }
+ 
+     public CKeyEntityB getUniqueB() {
+         return uniqueB;
+     }
+ 
+     public void setUniqueB(CKeyEntityB uniqueB) {
+         this.uniqueB = uniqueB;
+     }
+ }
================================================================================
Merge Diffs: /ade/tware_toplink10i/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/models/cmp3/ddlgeneration/CKeyEntityAPK.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1072_table_generation_wonsoek_kim_061107/ade_storage/000014/AB0952363AC40CBFE034080020E8C54E.0
Report generated at Tue Nov  7 10:57:21 2006
--------------------------------------------------------------------------------
*** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1072_table_generation_wonsoek_kim_061107/ade_storage/000014/AB0952363AC40CBFE034080020E8C54E.0	Tue Nov  7 10:55:32 2006
--- /ade/tware_toplink10i/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/models/cmp3/ddlgeneration/CKeyEntityAPK.java	Tue Nov  7 10:55:32 2006
***************
*** 0 ****
--- 1,37 ----
+ package oracle.toplink.essentials.testing.models.cmp3.ddlgeneration;
+ 
+ /**
+  * @author Wonseok Kim
+  */
+ public class CKeyEntityAPK {
+     public int seq;
+     public String firstName;
+     public String lastName;
+ 
+ 
+     public CKeyEntityAPK() {
+     }
+ 
+     public CKeyEntityAPK(int seq, String firstName, String lastName) {
+         this.seq = seq;
+         this.firstName = firstName;
+         this.lastName = lastName;
+     }
+ 
+     public boolean equals(Object o) {
+         if (this == o) return true;
+         if (o == null || getClass() != o.getClass()) return false;
+ 
+         CKeyEntityAPK that = (CKeyEntityAPK) o;
+ 
+         return seq == that.seq && firstName.equals(that.firstName) && lastName.equals(that.lastName);
+     }
+ 
+     public int hashCode() {
+         int result;
+         result = seq;
+         result = 31 * result + firstName.hashCode();
+         result = 31 * result + lastName.hashCode();
+         return result;
+     }
+ }
================================================================================
Merge Diffs: /ade/tware_toplink10i/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/models/cmp3/ddlgeneration/CKeyEntityB.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1072_table_generation_wonsoek_kim_061107/ade_storage/000015/AB0952363AC40CBFE034080020E8C54E.0
Report generated at Tue Nov  7 10:57:21 2006
--------------------------------------------------------------------------------
*** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1072_table_generation_wonsoek_kim_061107/ade_storage/000015/AB0952363AC40CBFE034080020E8C54E.0	Tue Nov  7 10:55:36 2006
--- /ade/tware_toplink10i/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/models/cmp3/ddlgeneration/CKeyEntityB.java	Tue Nov  7 10:55:35 2006
***************
*** 0 ****
--- 1,114 ----
+ package oracle.toplink.essentials.testing.models.cmp3.ddlgeneration;
+ 
+ import javax.persistence.Column;
+ import javax.persistence.Entity;
+ import javax.persistence.GeneratedValue;
+ import static javax.persistence.GenerationType.TABLE;
+ import javax.persistence.Id;
+ import javax.persistence.IdClass;
+ import javax.persistence.Inheritance;
+ import javax.persistence.InheritanceType;
+ import javax.persistence.ManyToMany;
+ import javax.persistence.OneToMany;
+ import javax.persistence.OneToOne;
+ import javax.persistence.Table;
+ import javax.persistence.UniqueConstraint;
+ import java.util.Collection;
+ 
+ /**
+  * Composite Key Entity.
+  * 
+  * @author Wonseok Kim
+  */
+ @Entity
+ @IdClass(CKeyEntityBPK.class)
+ @Inheritance(strategy = InheritanceType.JOINED)
+ @Table(name = "DDL_CKENTB", 
+     uniqueConstraints = { 
+         @UniqueConstraint(columnNames={"UNQ2, UNQ1"}) //The order of columns shoud not be changed. See CKeyEntityA. 
+ })
+ public class CKeyEntityB {
+     @Id
+     @GeneratedValue(strategy = TABLE, generator = "CKEYENTITY_TABLE_GENERATOR")
+     @Column(name = "SEQ")
+     private int seq;
+ 
+     @Id
+     @Column(name = "CODE")
+     private String code;
+     
+     @Column(name = "UNQ1", nullable = false)
+     private String unq1;
+ 
+     @Column(name = "UNQ2", nullable = false)
+     private String unq2;
+     
+ 
+     @OneToMany(mappedBy="bs")
+     private Collection<CKeyEntityA> as;
+     
+     @ManyToMany(mappedBy="bs")
+     private Collection<CKeyEntityC> cs;
+ 
+     @OneToOne(mappedBy="uniqueB")
+     private CKeyEntityA uniqueA;
+ 
+     public CKeyEntityB() {
+     }
+ 
+     public CKeyEntityB(String code) {
+         this.code = code;
+     }
+ 
+     public int getSeq() {
+         return seq;
+     }
+ 
+     public String getCode() {
+         return code;
+     }
+ 
+     public CKeyEntityBPK getKey() {
+         return new CKeyEntityBPK(seq, code);
+     }
+     
+     public String getUnq1() {
+         return unq1;
+     }
+ 
+     public void setUnq1(String unq1) {
+         this.unq1 = unq1;
+     }
+ 
+     public String getUnq2() {
+         return unq2;
+     }
+ 
+     public void setUnq2(String unq2) {
+         this.unq2 = unq2;
+     }
+ 
+     public Collection<CKeyEntityA> getAs() {
+         return as;
+     }
+ 
+     public void setAs(Collection<CKeyEntityA> as) {
+         this.as = as;
+     }
+ 
+     public Collection<CKeyEntityC> getCs() {
+         return cs;
+     }
+ 
+     public void setCs(Collection<CKeyEntityC> cs) {
+         this.cs = cs;
+     }
+ 
+     public CKeyEntityA getUniqueA() {
+         return uniqueA;
+     }
+ 
+     public void setUniqueA(CKeyEntityA uniqueA) {
+         this.uniqueA = uniqueA;
+     }
+ }
================================================================================
Merge Diffs: /ade/tware_toplink10i/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/models/cmp3/ddlgeneration/CKeyEntityB2.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1072_table_generation_wonsoek_kim_061107/ade_storage/000016/AB0952363AC40CBFE034080020E8C54E.0
Report generated at Tue Nov  7 10:57:21 2006
--------------------------------------------------------------------------------
*** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1072_table_generation_wonsoek_kim_061107/ade_storage/000016/AB0952363AC40CBFE034080020E8C54E.0	Tue Nov  7 10:55:40 2006
--- /ade/tware_toplink10i/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/models/cmp3/ddlgeneration/CKeyEntityB2.java	Tue Nov  7 10:55:39 2006
***************
*** 0 ****
--- 1,19 ----
+ package oracle.toplink.essentials.testing.models.cmp3.ddlgeneration;
+ 
+ import javax.persistence.Entity;
+ import javax.persistence.PrimaryKeyJoinColumn;
+ import javax.persistence.PrimaryKeyJoinColumns;
+ import javax.persistence.Table;
+ 
+ /**
+  * @author Wonseok Kim
+  */
+ @Entity
+ @Table(name="DDL_CKEYENTB2")
+ @PrimaryKeyJoinColumns({
+     @PrimaryKeyJoinColumn(name="SEQ", referencedColumnName="SEQ"),
+     @PrimaryKeyJoinColumn(name="CODE", referencedColumnName="CODE")
+ })
+ public class CKeyEntityB2 extends CKeyEntityB {
+     
+ }
================================================================================
Merge Diffs: /ade/tware_toplink10i/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/models/cmp3/ddlgeneration/CKeyEntityBPK.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1072_table_generation_wonsoek_kim_061107/ade_storage/000017/AB0952363AC40CBFE034080020E8C54E.0
Report generated at Tue Nov  7 10:57:21 2006
--------------------------------------------------------------------------------
*** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1072_table_generation_wonsoek_kim_061107/ade_storage/000017/AB0952363AC40CBFE034080020E8C54E.0	Tue Nov  7 10:55:44 2006
--- /ade/tware_toplink10i/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/models/cmp3/ddlgeneration/CKeyEntityBPK.java	Tue Nov  7 10:55:43 2006
***************
*** 0 ****
--- 1,33 ----
+ package oracle.toplink.essentials.testing.models.cmp3.ddlgeneration;
+ 
+ /**
+  * @author Wonseok Kim
+  */
+ public class CKeyEntityBPK {
+     public int seq;
+     public String code;
+ 
+     public CKeyEntityBPK() {
+     }
+ 
+     public CKeyEntityBPK(int seq, String code) {
+         this.seq = seq;
+         this.code = code;
+     }
+ 
+     public boolean equals(Object o) {
+         if (this == o) return true;
+         if (o == null || getClass() != o.getClass()) return false;
+ 
+         CKeyEntityBPK that = (CKeyEntityBPK) o;
+ 
+         return seq == that.seq && code.equals(that.code);
+     }
+ 
+     public int hashCode() {
+         int result;
+         result = seq;
+         result = 31 * result + (code != null ? code.hashCode() : 0);
+         return result;
+     }
+ }
================================================================================
Merge Diffs: /ade/tware_toplink10i/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/models/cmp3/ddlgeneration/CKeyEntityC.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1072_table_generation_wonsoek_kim_061107/ade_storage/000018/AB0952363AC40CBFE034080020E8C54E.0
Report generated at Tue Nov  7 10:57:21 2006
--------------------------------------------------------------------------------
*** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1072_table_generation_wonsoek_kim_061107/ade_storage/000018/AB0952363AC40CBFE034080020E8C54E.0	Tue Nov  7 10:55:48 2006
--- /ade/tware_toplink10i/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/models/cmp3/ddlgeneration/CKeyEntityC.java	Tue Nov  7 10:55:47 2006
***************
*** 0 ****
--- 1,87 ----
+ package oracle.toplink.essentials.testing.models.cmp3.ddlgeneration;
+ 
+ import javax.persistence.Column;
+ import javax.persistence.EmbeddedId;
+ import javax.persistence.Entity;
+ import javax.persistence.JoinColumn;
+ import javax.persistence.JoinColumns;
+ import javax.persistence.JoinTable;
+ import javax.persistence.ManyToMany;
+ import javax.persistence.OneToOne;
+ import javax.persistence.Table;
+ import java.util.Collection;
+ 
+ /**
+  * Composite Key Entity.
+  * 
+  * @author Wonseok Kim
+  */
+ @Entity
+ @Table(name = "DDL_CKENTC")
+ public class CKeyEntityC {
+ 
+     @EmbeddedId
+     private CKeyEntityCPK key;
+     
+     // Test for GF#1392
+     // If there is a same name column for the entity and many-to-many table, wrong pk constraint generated.
+     @Column(name="C_ROLE")
+     private String tempRole;
+ 
+     @OneToOne
+     @JoinColumns({
+         @JoinColumn(name="A_SEQ", referencedColumnName = "SEQ"),
+         @JoinColumn(name="A_L_NAME", referencedColumnName = "L_NAME"),
+         @JoinColumn(name="A_F_NAME", referencedColumnName = "F_NAME")
+     })
+     private CKeyEntityA a;
+     
+     @ManyToMany
+         @JoinTable(name="DDL_CKENT_C_B",
+         joinColumns={
+             @JoinColumn(name="C_SEQ", referencedColumnName="SEQ"),
+             @JoinColumn(name="C_ROLE", referencedColumnName="ROLE")
+         },
+         inverseJoinColumns={
+             @JoinColumn(name="B_SEQ", referencedColumnName = "SEQ"),
+             @JoinColumn(name="B_CODE", referencedColumnName = "CODE")
+         }
+     )
+     private Collection<CKeyEntityB> bs;
+ 
+ 
+     public CKeyEntityC() {
+     }
+ 
+     public CKeyEntityC(CKeyEntityCPK key) {
+         this.key = key;
+     }
+ 
+     public CKeyEntityCPK getKey() {
+         return key;
+     }
+ 
+     public String getTempRole() {
+         return tempRole;
+     }
+ 
+     public void setTempRole(String tempRole) {
+         this.tempRole = tempRole;
+     }
+ 
+     public CKeyEntityA getA() {
+         return a;
+     }
+ 
+     public void setA(CKeyEntityA a) {
+         this.a = a;
+     }
+ 
+     public Collection<CKeyEntityB> getBs() {
+         return bs;
+     }
+ 
+     public void setBs(Collection<CKeyEntityB> bs) {
+         this.bs = bs;
+     }
+ }
================================================================================
Merge Diffs: /ade/tware_toplink10i/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/models/cmp3/ddlgeneration/CKeyEntityCPK.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1072_table_generation_wonsoek_kim_061107/ade_storage/000019/AB0952363AC40CBFE034080020E8C54E.0
Report generated at Tue Nov  7 10:57:21 2006
--------------------------------------------------------------------------------
*** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1072_table_generation_wonsoek_kim_061107/ade_storage/000019/AB0952363AC40CBFE034080020E8C54E.0	Tue Nov  7 10:55:52 2006
--- /ade/tware_toplink10i/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/models/cmp3/ddlgeneration/CKeyEntityCPK.java	Tue Nov  7 10:55:51 2006
***************
*** 0 ****
--- 1,43 ----
+ package oracle.toplink.essentials.testing.models.cmp3.ddlgeneration;
+ 
+ import javax.persistence.Column;
+ import javax.persistence.Embeddable;
+ import javax.persistence.GeneratedValue;
+ import static javax.persistence.GenerationType.TABLE;
+ 
+ /**
+  * @author Wonseok Kim
+  */
+ @Embeddable
+ public class CKeyEntityCPK {
+     @GeneratedValue(strategy = TABLE, generator = "CKEYENTITY_TABLE_GENERATOR")
+     @Column(name = "SEQ")
+     public int seq;
+ 
+     @Column(name = "ROLE")
+     public String role;
+ 
+ 
+     public CKeyEntityCPK() {
+     }
+ 
+     public CKeyEntityCPK(String role) {
+         this.role = role;
+     }
+ 
+     public boolean equals(Object o) {
+         if (this == o) return true;
+         if (o == null || getClass() != o.getClass()) return false;
+ 
+         CKeyEntityCPK that = (CKeyEntityCPK) o;
+ 
+         return seq == that.seq && role.equals(that.role);
+     }
+ 
+     public int hashCode() {
+         int result;
+         result = seq;
+         result = 31 * result + role.hashCode();
+         return result;
+     }
+ }
================================================================================
Merge Diffs: /ade/tware_toplink10i/tltest/resource/essentials/ddl-generation-testmodel/META-INF/persistence.xml vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1072_table_generation_wonsoek_kim_061107/ade_storage/000020/AB0952363AC40CBFE034080020E8C54E.3
Report generated at Tue Nov  7 10:57:21 2006
--------------------------------------------------------------------------------
*** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1072_table_generation_wonsoek_kim_061107/ade_storage/000020/AB0952363AC40CBFE034080020E8C54E.3	Tue Nov  7 09:11:29 2006
--- /ade/tware_toplink10i/tltest/resource/essentials/ddl-generation-testmodel/META-INF/persistence.xml	Tue Nov  7 10:57:21 2006
***************
*** 11,16 ****
--- 11,17 ----
          <mapping-file>META-INF/merge-inherited-beers.xml</mapping-file>
          <mapping-file>META-INF/merge-inherited-consumer.xml</mapping-file>
          <mapping-file>META-INF/merge-inherited-certification.xml</mapping-file>
+         <mapping-file>META-INF/ddl-generation-model.xml</mapping-file>
          <class>oracle.toplink.essentials.testing.models.cmp3.xml.merge.inherited.EmbeddedSerialNumber</class>
          <properties>
              <property name="toplink.session-name" value="mergeinherited-session"/>
***************
*** 24,40 ****
              <property name="toplink.jdbc.read-connections.min" value="3"/>
              <property name="toplink.jdbc.read-connections.max" value="3"/>
              <property name="toplink.cache.size.default" value="500"/>
-             <property name="toplink.cache.size.Employee" value="550"/>
-             <property name="toplink.cache.size.oracle.toplink.essentials.testing.models.cmp3.advanced.Address" value="555"/>
              <property name="toplink.cache.type.default" value="Full"/>
-             <property name="toplink.cache.type.Employee" value="Weak"/>
-             <property name="toplink.cache.type.oracle.toplink.essentials.testing.models.cmp3.advanced.Address" value="HardWeak"/>
              <property name="toplink.session.customizer" value="oracle.toplink.essentials.testing.models.cmp3.advanced.Customizer"/>
-             <property name="toplink.descriptor.customizer.Employee" value="oracle.toplink.essentials.testing.models.cmp3.advanced.Customizer"/>
-             <property name="toplink.descriptor.customizer.oracle.toplink.essentials.testing.models.cmp3.advanced.Address" value="oracle.toplink.essentials.testing.models.cmp3.advanced.Customizer"/>
              <!--property name="toplink.logging.level" value="FINEST"/-->
              <property name="toplink.orm.throw.exceptions" value="true"/>
              <property name="toplink.ddl-generation" value="drop-and-create-tables"/>
          </properties>
      </persistence-unit>
  </persistence>
--- 25,37 ----
              <property name="toplink.jdbc.read-connections.min" value="3"/>
              <property name="toplink.jdbc.read-connections.max" value="3"/>
              <property name="toplink.cache.size.default" value="500"/>
              <property name="toplink.cache.type.default" value="Full"/>
              <property name="toplink.session.customizer" value="oracle.toplink.essentials.testing.models.cmp3.advanced.Customizer"/>
              <!--property name="toplink.logging.level" value="FINEST"/-->
              <property name="toplink.orm.throw.exceptions" value="true"/>
              <property name="toplink.ddl-generation" value="drop-and-create-tables"/>
+             <property name="toplink.create-ddl-jdbc-file-name" value="createDDL_ddlGeneration.jdbc"/>
+             <property name="toplink.drop-ddl-jdbc-file-name" value="dropDDL_ddlGeneration.jdbc"/>
          </properties>
      </persistence-unit>
  </persistence>
================================================================================
Merge Diffs: /ade/tware_toplink10i/tltest/resource/essentials/ddl-generation-testmodel/META-INF/ddl-generation-model.xml vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1072_table_generation_wonsoek_kim_061107/ade_storage/000022/AB0952363AC40CBFE034080020E8C54E.0
Report generated at Tue Nov  7 10:57:21 2006
--------------------------------------------------------------------------------
*** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1072_table_generation_wonsoek_kim_061107/ade_storage/000022/AB0952363AC40CBFE034080020E8C54E.0	Tue Nov  7 10:56:01 2006
--- /ade/tware_toplink10i/tltest/resource/essentials/ddl-generation-testmodel/META-INF/ddl-generation-model.xml	Tue Nov  7 10:56:00 2006
***************
*** 0 ****
--- 1,10 ----
+ <?xml version="1.0" encoding="UTF-8"?>
+ <entity-mappings version="1.0" xmlns="http://java.sun.com/xml/ns/persistence/orm" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm orm_1_0.xsd">
+     <package>oracle.toplink.essentials.testing.models.cmp3.ddlgeneration</package>
+ 
+     <entity class="CKeyEntityA"/>
+     <entity class="CKeyEntityB"/>
+     <entity class="CKeyEntityB2"/>
+     <entity class="CKeyEntityC"/>
+     
+ </entity-mappings>
================================================================================
Merge Diffs: /ade/tware_toplink10i/tltest/build.xml vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1072_table_generation_wonsoek_kim_061107/ade_storage/000023/AB0952363AC40CBFE034080020E8C54E.42
Report generated at Tue Nov  7 10:57:21 2006
--------------------------------------------------------------------------------
*** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1072_table_generation_wonsoek_kim_061107/ade_storage/000023/AB0952363AC40CBFE034080020E8C54E.42	Tue Nov  7 09:39:40 2006
--- /ade/tware_toplink10i/tltest/build.xml	Tue Nov  7 10:57:21 2006
***************
*** 387,393 ****
                  dir="${compile.essentials.destdir}"
                  includes="oracle/toplink/essentials/testing/models/cmp3/**"
                  excludes="oracle/toplink/essentials/testing/models/cmp3/validationfailed/**,
!                           oracle/toplink/essentials/testing/models/cmp3/xml/**"
              />
              <fileset
                  dir="${compile.essentials.resources}/ejb30-testing"
--- 387,394 ----
                  dir="${compile.essentials.destdir}"
                  includes="oracle/toplink/essentials/testing/models/cmp3/**"
                  excludes="oracle/toplink/essentials/testing/models/cmp3/validationfailed/**,
!                           oracle/toplink/essentials/testing/models/cmp3/xml/**,
!                           oracle/toplink/essentials/testing/models/cmp3/ddlgeneration/**"
              />
              <fileset
                  dir="${compile.essentials.resources}/ejb30-testing"
***************
*** 449,455 ****
          <jar jarfile="${_jarDestDir}/${ddl_generation_testmodel.jarfile}">
              <fileset
                  dir="${compile.essentials.destdir}"
!                 includes="oracle/toplink/essentials/testing/models/cmp3/xml/merge/inherited/**"
              />
              <fileset
                  dir="${compile.essentials.resources}/ddl-generation-testmodel"
--- 450,457 ----
          <jar jarfile="${_jarDestDir}/${ddl_generation_testmodel.jarfile}">
              <fileset
                  dir="${compile.essentials.destdir}"
!                 includes="oracle/toplink/essentials/testing/models/cmp3/xml/merge/inherited/**,
! 		          oracle/toplink/essentials/testing/models/cmp3/ddlgeneration/**"
              />
              <fileset
                  dir="${compile.essentials.resources}/ddl-generation-testmodel"
================================================================================
Merge Diffs: /ade/tware_toplink10i/tltest/test/data/tle.xml vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1072_table_generation_wonsoek_kim_061107/ade_storage/000024/AB0952363AC40CBFE034080020E8C54E.11
Report generated at Tue Nov  7 10:57:21 2006
--------------------------------------------------------------------------------
*** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1072_table_generation_wonsoek_kim_061107/ade_storage/000024/AB0952363AC40CBFE034080020E8C54E.11	Tue Nov  7 09:55:21 2006
--- /ade/tware_toplink10i/tltest/test/data/tle.xml	Tue Nov  7 10:57:21 2006
***************
*** 205,211 ****
  				<fileset dir="${toplink.testing.weaving.temp.dir.name}"
  					includes="oracle/toplink/essentials/testing/models/cmp3/**/*.class"
  					excludes="oracle/toplink/essentials/testing/models/cmp3/validationfailed/**/*.class,
! 						      oracle/toplink/essentials/testing/models/cmp3/xml/**/*.class"
  				/>
  			</copy>
  			<jar destfile="${toplink.testing.weaving.temp.dir.name}/toplink-essentials-annotation-model-tests.jar" basedir="${toplink.testing.weaving.temp.dir.name}_annotation"/>
--- 205,212 ----
  				<fileset dir="${toplink.testing.weaving.temp.dir.name}"
  					includes="oracle/toplink/essentials/testing/models/cmp3/**/*.class"
  					excludes="oracle/toplink/essentials/testing/models/cmp3/validationfailed/**/*.class,
! 						      oracle/toplink/essentials/testing/models/cmp3/xml/**/*.class,
! 						  oracle/toplink/essentials/testing/models/cmp3/ddlgeneration/**/*.class"
  				/>
  			</copy>
  			<jar destfile="${toplink.testing.weaving.temp.dir.name}/toplink-essentials-annotation-model-tests.jar" basedir="${toplink.testing.weaving.temp.dir.name}_annotation"/>
================================================================================
Merge Diffs: /ade/tware_toplink10i/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/tests/FullRegressionTestSuite.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1072_table_generation_wonsoek_kim_061107/ade_storage/000001/AB0952363AC40CBFE034080020E8C54E.25
Report generated at Tue Nov  7 11:21:53 2006
--------------------------------------------------------------------------------
*** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1072_table_generation_wonsoek_kim_061107/ade_storage/000001/AB0952363AC40CBFE034080020E8C54E.25	Mon Nov  6 14:11:37 2006
--- /ade/tware_toplink10i/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/tests/FullRegressionTestSuite.java	Tue Nov  7 10:57:21 2006
***************
*** 63,70 ****
  import oracle.toplink.essentials.testing.tests.ejb.ejbqltesting.JUnitEJBQLModifyTestSuite;
  
  import oracle.toplink.essentials.testing.tests.cmp3.xml.EntityMappingsJUnitTestSuite;
  import oracle.toplink.essentials.testing.tests.ejb.ejbqltesting.JUnitEJBQLInheritanceTestSuite;
- import oracle.toplink.essentials.testing.tests.cmp3.instancecounting.MemoryLeakJUnitTestSuite;
  
  public class FullRegressionTestSuite extends TestSuite{
      
--- 63,70 ----
  import oracle.toplink.essentials.testing.tests.ejb.ejbqltesting.JUnitEJBQLModifyTestSuite;
  
  import oracle.toplink.essentials.testing.tests.cmp3.xml.EntityMappingsJUnitTestSuite;
+ import oracle.toplink.essentials.testing.tests.cmp3.ddlgeneration.DDLGenerationJUnitTestSuite;
  import oracle.toplink.essentials.testing.tests.ejb.ejbqltesting.JUnitEJBQLInheritanceTestSuite;
  
  public class FullRegressionTestSuite extends TestSuite{
      
***************
*** 113,121 ****
          fullSuite.addTest(QueryParameterValidationTestSuite.suite());
          fullSuite.addTest(UniAndBiDirectionalMappingTestSuite.suite());
          
-         // Instance Counting Model
-         fullSuite.addTest(MemoryLeakJUnitTestSuite.suite());
-         
          // EJBQL testing model
          fullSuite.addTest(JUnitEJBQLUnitTestSuite.suite());
          fullSuite.addTest(JUnitEJBQLSimpleTestSuite.suite());
--- 113,118 ----
***************
*** 131,136 ****
--- 128,136 ----
          // XML model
          fullSuite.addTest(EntityMappingsJUnitTestSuite.suite());
  
+         // DDL model
+         fullSuite.addTest(DDLGenerationJUnitTestSuite.suite());
+ 
          return fullSuite;
      }
      
================================================================================
Merge Diffs: /ade/tware_toplink10i/tldev/source/essentials/oracle/toplink/essentials/tools/schemaframework/TableDefinition.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1072_table_generation_wonsoek_kim_061107/ade_storage/000002/AB0952363AC40CBFE034080020E8C54E.9
Report generated at Tue Nov  7 11:21:53 2006
--------------------------------------------------------------------------------
*** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1072_table_generation_wonsoek_kim_061107/ade_storage/000002/AB0952363AC40CBFE034080020E8C54E.9	Mon Nov  6 14:28:26 2006
--- /ade/tware_toplink10i/tldev/source/essentials/oracle/toplink/essentials/tools/schemaframework/TableDefinition.java	Tue Nov  7 10:57:21 2006
***************
*** 27,32 ****
--- 27,33 ----
  import oracle.toplink.essentials.internal.databaseaccess.*;
  import oracle.toplink.essentials.exceptions.*;
  import oracle.toplink.essentials.internal.sessions.AbstractSession;
+ import oracle.toplink.essentials.queryframework.SQLCall;
  
  /**
   * <p>
***************
*** 34,41 ****
   * <p>
   */
  public class TableDefinition extends DatabaseObjectDefinition {
!     protected Vector fields;
!     protected Vector foreignKeys;
      protected Vector uniqueKeys;
      protected String creationPrefix;
      protected String creationSuffix;
--- 35,42 ----
   * <p>
   */
  public class TableDefinition extends DatabaseObjectDefinition {
!     protected Vector fields; //FieldDefinitions
!     protected HashMap<String, ForeignKeyConstraint> foreignKeyMap; //key is the name of ForeignKeyConstraint
      protected Vector uniqueKeys;
      protected String creationPrefix;
      protected String creationSuffix;
***************
*** 43,49 ****
  
      public TableDefinition() {
          this.fields = new Vector();
!         this.foreignKeys = new Vector();
          this.uniqueKeys = new Vector();
          this.creationPrefix = "CREATE TABLE ";
          this.creationSuffix = "";
--- 44,50 ----
  
      public TableDefinition() {
          this.fields = new Vector();
!         this.foreignKeyMap = new HashMap<String, ForeignKeyConstraint>();
          this.uniqueKeys = new Vector();
          this.creationPrefix = "CREATE TABLE ";
          this.creationSuffix = "";
***************
*** 96,101 ****
--- 97,103 ----
      /**
       * PUBLIC:
       * Add a foreign key constraint to the table.
+      * If there is a same name foreign key constraint already, nothing will happen.
       */
      public void addForeignKeyConstraint(String name, String sourceField, String targetField, String targetTable) {
          ForeignKeyConstraint foreignKey = new ForeignKeyConstraint(name, sourceField, targetField, targetTable);
***************
*** 114,122 ****
      /**
       * PUBLIC:
       * Add a foreign key constraint to the table.
       */
      public void addForeignKeyConstraint(ForeignKeyConstraint foreignKey) {
!         getForeignKeys().addElement(foreignKey);
      }
      
      /**
--- 116,127 ----
      /**
       * PUBLIC:
       * Add a foreign key constraint to the table.
+      * If there is a same name foreign key constraint already, nothing will happen.
       */
      public void addForeignKeyConstraint(ForeignKeyConstraint foreignKey) {
!         if (!foreignKeyMap.containsKey(foreignKey.getName())) {
!             foreignKeyMap.put(foreignKey.getName(), foreignKey);
!         }
      }
      
      /**
***************
*** 371,384 ****
      private void buildForeignFieldTypes(final AbstractSession session) {
          Hashtable fieldTypes = session.getPlatform().getClassTypes();
          FieldDefinition field = null;
-         DatabaseField dbField = null;
          
!         Vector foreignKeysClone = (Vector)getForeignKeys().clone();          
!         setForeignKeys(new Vector());
          for (Enumeration enumtr = getFields().elements(); enumtr.hasMoreElements();) {
              field = (FieldDefinition)enumtr.nextElement();
              if (field.getForeignKeyFieldName() != null) {
!                 addForeignKeyConstraint(buildForeignKeyConstraint(field, this, session.getPlatform()));
  
              }
              if (field.getType() == null) {
--- 376,390 ----
      private void buildForeignFieldTypes(final AbstractSession session) {
          Hashtable fieldTypes = session.getPlatform().getClassTypes();
          FieldDefinition field = null;
          
!         // The ForeignKeyConstraint object is the newer way of doing things.
!         // We support FieldDefinition.getForeignKeyFieldName() due to backwards compatibility
!         // by converting it. To allow mixing both ways, we just add converted one to foreignKeys list.
!         
          for (Enumeration enumtr = getFields().elements(); enumtr.hasMoreElements();) {
              field = (FieldDefinition)enumtr.nextElement();
              if (field.getForeignKeyFieldName() != null) {
!                 addForeignKeyConstraint(buildForeignKeyConstraint(field, session.getPlatform()));
  
              }
              if (field.getType() == null) {
***************
*** 389,403 ****
              }
          }
  
-         /* bug #2997188 constraints not getting generated when creating/replacing tables via TableCreator
-            had to add the next few lines instead of removing the above code for backwards compatibility */
-         if (getForeignKeys().isEmpty()) {
-             //if foreignKeys is empty then we know we are not in 2.5
-             setForeignKeys(foreignKeysClone);
-         }
      }
  
!     protected ForeignKeyConstraint buildForeignKeyConstraint(FieldDefinition field, TableDefinition table, DatabasePlatform platform) {
          Vector sourceFields = new Vector();
          Vector targetFields = new Vector();
          ForeignKeyConstraint fkConstraint = new ForeignKeyConstraint();
--- 395,406 ----
              }
          }
  
      }
  
!     /**
!      * Build a foriegn key constraint using FieldDefinition.getForeignKeyFieldName().
!      */
!     protected ForeignKeyConstraint buildForeignKeyConstraint(FieldDefinition field, DatabasePlatform platform) {
          Vector sourceFields = new Vector();
          Vector targetFields = new Vector();
          ForeignKeyConstraint fkConstraint = new ForeignKeyConstraint();
***************
*** 410,422 ****
          fkConstraint.setSourceFields(sourceFields);
          fkConstraint.setTargetFields(targetFields);
          fkConstraint.setTargetTable(tempTargetField.getTable().getQualifiedName());
!         String tempName = buildForeignKeyConstraintName(table.getName(), tempSourceField.getName(), platform.getMaxForeignKeyNameSize());
  
          fkConstraint.setName(tempName);
          return fkConstraint;
      }
  
      /**
       * Return foreign key constraint name built from the table and field name with the specified maximum length. To
       * make the name short enough we
       * 1. Drop the "FK_" prefix.
--- 413,445 ----
          fkConstraint.setSourceFields(sourceFields);
          fkConstraint.setTargetFields(targetFields);
          fkConstraint.setTargetTable(tempTargetField.getTable().getQualifiedName());
!         String tempName = buildForeignKeyConstraintName(this.getName(), tempSourceField.getName(), platform.getMaxForeignKeyNameSize());
  
          fkConstraint.setName(tempName);
          return fkConstraint;
      }
  
      /**
+      * Build a foriegn key constraint.
+      */
+     protected ForeignKeyConstraint buildForeignKeyConstraint(Vector fkFieldNames, Vector pkFieldNames, TableDefinition targetTable, DatabasePlatform platform) {
+         assert fkFieldNames.size() > 0 && fkFieldNames.size() == pkFieldNames.size();
+         
+         ForeignKeyConstraint fkConstraint = new ForeignKeyConstraint();
+         for(int i=0; i<fkFieldNames.size(); i++) {
+             fkConstraint.getSourceFields().add((String)fkFieldNames.get(i));
+             fkConstraint.getTargetFields().add((String)pkFieldNames.get(i));
+         }
+ 
+         fkConstraint.setTargetTable(targetTable.getFullName());
+         String fkFieldName = (String)fkFieldNames.get(0);
+         String name = buildForeignKeyConstraintName(this.getName(), fkFieldName, platform.getMaxForeignKeyNameSize());
+ 
+         fkConstraint.setName(name);
+         return fkConstraint;
+     }
+ 
+     /**
       * Return foreign key constraint name built from the table and field name with the specified maximum length. To
       * make the name short enough we
       * 1. Drop the "FK_" prefix.
***************
*** 500,507 ****
                  clone.addField((FieldDefinition)fieldDef.clone());
              }
          }
!         if (foreignKeys != null) {
!             clone.setForeignKeys((Vector)foreignKeys.clone());
          }
          if (uniqueKeys != null) {
              clone.setUniqueKeys((Vector)uniqueKeys.clone());
--- 523,530 ----
                  clone.addField((FieldDefinition)fieldDef.clone());
              }
          }
!         if (foreignKeyMap != null) {
!             clone.setForeignKeyMap((HashMap) foreignKeyMap.clone());
          }
          if (uniqueKeys != null) {
              clone.setUniqueKeys((Vector)uniqueKeys.clone());
***************
*** 514,529 ****
       * Execute the SQL alter table constraint creation string.
       */
      public void createConstraints(AbstractSession session, Writer schemaWriter) throws TopLinkException {       
!         if (schemaWriter == null) {
!             this.createConstraintsOnDatabase(session);
!         } else {
!             createForeignConstraints(session, schemaWriter);
!             createUniqueContraints(session, schemaWriter);            
!             
!         }
      }
  
!     private void createUniqueContraints(final AbstractSession session, final Writer schemaWriter) throws ValidationException {       
          for (Enumeration uniqueKeysEnum = getUniqueKeys().elements();
                   uniqueKeysEnum.hasMoreElements();) {              
              UniqueKeyConstraint uniqueKey = (UniqueKeyConstraint)uniqueKeysEnum.nextElement();
--- 537,552 ----
       * Execute the SQL alter table constraint creation string.
       */
      public void createConstraints(AbstractSession session, Writer schemaWriter) throws TopLinkException {       
!         createUniqueConstraints(session, schemaWriter);
!         createForeignConstraints(session, schemaWriter);
      }
  
!     void createUniqueConstraints(final AbstractSession session, final Writer schemaWriter) throws ValidationException {
!         if (schemaWriter == null) {
!             createUniqueConstraintsOnDatabase(session);
!             return;
!         }
!         
          for (Enumeration uniqueKeysEnum = getUniqueKeys().elements();
                   uniqueKeysEnum.hasMoreElements();) {              
              UniqueKeyConstraint uniqueKey = (UniqueKeyConstraint)uniqueKeysEnum.nextElement();
***************
*** 539,551 ****
          }            
      }
  
!     private void createForeignConstraints(final AbstractSession session, final Writer schemaWriter) throws ValidationException {
!         for (Enumeration foreignKeysEnum = getForeignKeys().elements();
!                  foreignKeysEnum.hasMoreElements();) {
!             ForeignKeyConstraint foreignKey = (ForeignKeyConstraint)foreignKeysEnum.nextElement();
              buildConstraintCreationWriter(session, foreignKey, schemaWriter).toString();
              try {
!                 if (createSQLFiles){                    
                      schemaWriter.write(session.getPlatform().getStoredProcedureTerminationToken());
                  }
                  schemaWriter.write("\n");
--- 562,577 ----
          }            
      }
  
!     void createForeignConstraints(final AbstractSession session, final Writer schemaWriter) throws ValidationException {
!         if (schemaWriter == null) {
!             createForeignConstraintsOnDatabase(session);
!             return;
!         }
!         
!         for (ForeignKeyConstraint foreignKey : getForeignKeyMap().values()) {
              buildConstraintCreationWriter(session, foreignKey, schemaWriter).toString();
              try {
!                 if (createSQLFiles) {
                      schemaWriter.write(session.getPlatform().getStoredProcedureTerminationToken());
                  }
                  schemaWriter.write("\n");
***************
*** 560,570 ****
       * Execute the SQL alter table constraint creation string.
       */
      public void createConstraintsOnDatabase(AbstractSession session) throws TopLinkException {
-         createForeignConstraintsOnDatabase(session);
          createUniqueConstraintsOnDatabase(session);       
      }
  
!     private void createUniqueConstraintsOnDatabase(final AbstractSession session) throws ValidationException, DatabaseException {       
          if ((!session.getPlatform().supportsUniqueKeyConstraints()) || getUniqueKeys().isEmpty()) {
              return;
          }
--- 586,596 ----
       * Execute the SQL alter table constraint creation string.
       */
      public void createConstraintsOnDatabase(AbstractSession session) throws TopLinkException {
          createUniqueConstraintsOnDatabase(session);       
+         createForeignConstraintsOnDatabase(session);
      }
  
!     void createUniqueConstraintsOnDatabase(final AbstractSession session) throws ValidationException, DatabaseException {       
          if ((!session.getPlatform().supportsUniqueKeyConstraints()) || getUniqueKeys().isEmpty()) {
              return;
          }
***************
*** 576,590 ****
          } 
      }
  
!     private void createForeignConstraintsOnDatabase(final AbstractSession session) throws ValidationException, DatabaseException {        
!         if ((!session.getPlatform().supportsForeignKeyConstraints()) || getForeignKeys().isEmpty()) {
              return;
          }
  
!         for (Enumeration foreignKeysEnum = getForeignKeys().elements();
!                  foreignKeysEnum.hasMoreElements();) {
!             ForeignKeyConstraint foreignKey = (ForeignKeyConstraint)foreignKeysEnum.nextElement();
!             session.executeNonSelectingCall(new oracle.toplink.essentials.queryframework.SQLCall(buildConstraintCreationWriter(session, foreignKey, new StringWriter()).toString()));
          }
      }
  
--- 602,614 ----
          } 
      }
  
!     void createForeignConstraintsOnDatabase(final AbstractSession session) throws ValidationException, DatabaseException {        
!         if ((!session.getPlatform().supportsForeignKeyConstraints()) || getForeignKeyMap().isEmpty()) {
              return;
          }
  
!         for (ForeignKeyConstraint foreignKey : getForeignKeyMap().values()) {
!             session.executeNonSelectingCall(new SQLCall(buildConstraintCreationWriter(session, foreignKey, new StringWriter()).toString()));
          }
      }
  
***************
*** 604,612 ****
          if (schemaWriter == null) {
              this.dropConstraintsOnDatabase(session);
          } else {
!             for (Enumeration foreignKeysEnum = getForeignKeys().elements();
!                      foreignKeysEnum.hasMoreElements();) {
!                 ForeignKeyConstraint foreignKey = (ForeignKeyConstraint)foreignKeysEnum.nextElement();
                  buildConstraintDeletionWriter(session, foreignKey, schemaWriter).toString();
                  try {
                      if (createSQLFiles) {
--- 628,634 ----
          if (schemaWriter == null) {
              this.dropConstraintsOnDatabase(session);
          } else {
!             for (ForeignKeyConstraint foreignKey : getForeignKeyMap().values()) {
                  buildConstraintDeletionWriter(session, foreignKey, schemaWriter).toString();
                  try {
                      if (createSQLFiles) {
***************
*** 660,691 ****
      }
  
      private void dropForeignConstraintsOnDatabase(final AbstractSession session) throws ValidationException {        
!         if ((!session.getPlatform().supportsForeignKeyConstraints()) || getForeignKeys().isEmpty()) {
              return;
          } 
  
!         for (Enumeration foreignKeysEnum = getForeignKeys().elements();
!                  foreignKeysEnum.hasMoreElements();) {
!             ForeignKeyConstraint foreignKey = (ForeignKeyConstraint)foreignKeysEnum.nextElement();
              try {
!                 session.executeNonSelectingCall(new oracle.toplink.essentials.queryframework.SQLCall(buildConstraintDeletionWriter(session, foreignKey, new StringWriter()).toString()));
              } catch (DatabaseException ex) {/* ignore */
              }
          }
      }
  
      public Vector getFields() {
          return fields;
      }
  
!     public Vector getForeignKeys() {
!         return foreignKeys;
      }
  
      public Vector getUniqueKeys() {
          return uniqueKeys;
      }
      
      public Vector getPrimaryKeyFieldNames() {
          Vector keyNames = new Vector();
  
--- 682,739 ----
      }
  
      private void dropForeignConstraintsOnDatabase(final AbstractSession session) throws ValidationException {        
!         if ((!session.getPlatform().supportsForeignKeyConstraints()) || getForeignKeyMap().isEmpty()) {
              return;
          } 
  
!         for (ForeignKeyConstraint foreignKey : getForeignKeyMap().values()) {
              try {
!                 session.executeNonSelectingCall(new SQLCall(buildConstraintDeletionWriter(session, foreignKey, new StringWriter()).toString()));
              } catch (DatabaseException ex) {/* ignore */
              }
          }
      }
  
+ 
+     /**
+      * INTERNAL:
+      */
+     HashMap<String, ForeignKeyConstraint> getForeignKeyMap() {
+         return foreignKeyMap;
+     }
+ 
+     /**
+      * INTERNAL:
+      */
+     void setForeignKeyMap(HashMap<String, ForeignKeyConstraint> foreignKeyMap) {
+         this.foreignKeyMap = foreignKeyMap;
+     }
+ 
+     /**
+      * PUBLIC:
+      */
      public Vector getFields() {
          return fields;
      }
  
!     /**
!      * PUBLIC:
!      * Returns the ForeignKeyConstraint list.
!      */
!     public Vector<ForeignKeyConstraint> getForeignKeys() {
!         return new Vector<ForeignKeyConstraint>(foreignKeyMap.values());
      }
  
+     /**
+      * PUBLIC:
+      */
      public Vector getUniqueKeys() {
          return uniqueKeys;
      }
      
+     /**
+      * PUBLIC:
+      */
      public Vector getPrimaryKeyFieldNames() {
          Vector keyNames = new Vector();
  
***************
*** 698,715 ****
          return keyNames;
      }
  
      public void setFields(Vector fields) {
          this.fields = fields;
      }
  
!     public void setForeignKeys(Vector foreignKeys) {
!         this.foreignKeys = foreignKeys;
      }
      
      public void setUniqueKeys(Vector uniqueKeys) {
          this.uniqueKeys = uniqueKeys;
      }
      
      public void setCreateSQLFiles(boolean genFlag) {
          this.createSQLFiles = genFlag;
      }    
--- 746,782 ----
          return keyNames;
      }
  
+     /**
+      * PUBLIC:
+      */
      public void setFields(Vector fields) {
          this.fields = fields;
      }
  
!     /**
!      * PUBLIC:
!      * Set the ForeignKeyConstraint list.
!      * If the list contains the same name foreign key constraints, only the first one of that name will be added.
!      */
!     public void setForeignKeys(Vector<ForeignKeyConstraint> foreignKeys) {
!         foreignKeyMap.clear();
!         if (foreignKeys != null) {
!             for(ForeignKeyConstraint foreignKey : foreignKeys) {
!                 foreignKeyMap.put(foreignKey .getName(), foreignKey);
!             }
!         }
      }
      
+     /**
+      * PUBLIC:
+      */
      public void setUniqueKeys(Vector uniqueKeys) {
          this.uniqueKeys = uniqueKeys;
      }
      
+     /**
+      * PUBLIC:
+      */
      public void setCreateSQLFiles(boolean genFlag) {
          this.createSQLFiles = genFlag;
      }    
================================================================================
Merge Diffs: /ade/tware_toplink10i/tldev/source/essentials/oracle/toplink/essentials/tools/schemaframework/DefaultTableGenerator.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1072_table_generation_wonsoek_kim_061107/ade_storage/000003/AB0952363AC40CBFE034080020E8C54E.13
Report generated at Tue Nov  7 11:21:53 2006
--------------------------------------------------------------------------------
*** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1072_table_generation_wonsoek_kim_061107/ade_storage/000003/AB0952363AC40CBFE034080020E8C54E.13	Mon Nov  6 14:28:29 2006
--- /ade/tware_toplink10i/tldev/source/essentials/oracle/toplink/essentials/tools/schemaframework/DefaultTableGenerator.java	Tue Nov  7 10:57:21 2006
***************
*** 24,30 ****
  import java.sql.ResultSet;
  import java.sql.SQLException;
  import java.util.HashMap;
- import java.util.Hashtable;
  import java.util.Iterator;
  import java.util.Map;
  import java.util.Vector;
--- 24,29 ----
***************
*** 45,50 ****
--- 44,50 ----
  
  import oracle.toplink.essentials.descriptors.ClassDescriptor;
  import oracle.toplink.essentials.internal.sessions.AbstractSession;
+ import oracle.toplink.essentials.internal.databaseaccess.DatabasePlatform;
  import oracle.toplink.essentials.mappings.OneToManyMapping;
  import oracle.toplink.essentials.mappings.OneToOneMapping;
  import oracle.toplink.essentials.sessions.Project;
***************
*** 93,98 ****
--- 93,101 ----
      //the project object used to generate the default data schema.
      Project project = null;
  
+     //the target database platform
+     private DatabasePlatform databasePlatform;
+     
      //used to track the table definition: keyed by the table name, and valued
      //by the table definition object
      private Map tableMap = null;
***************
*** 106,111 ****
--- 109,115 ----
       */
      public DefaultTableGenerator(Project project) {
          this.project = project;
+         databasePlatform = project.getLogin().getPlatform();
          tableMap = new HashMap();
          fieldMap = new HashMap();
      }
***************
*** 124,130 ****
  
              //aggregate RelationalDescriptor does not contains table/field data
              if (!desc.isAggregateDescriptor()) {
!                 initTableSchema((ClassDescriptor)desc);
              }
          }
  
--- 128,134 ----
  
              //aggregate RelationalDescriptor does not contains table/field data
              if (!desc.isAggregateDescriptor()) {
!                 initTableSchema(desc);
              }
          }
  
***************
*** 297,332 ****
          //first create relation table
          TableDefinition tblDef = getTableDefFromDBTable(mapping.getRelationTable());
  
-         DatabaseField dbField = null;
-         DatabaseField parentDBField = null;
-         FieldDefinition fldDef = null;
- 
          //add source foreign key fields into the relation table
          Vector srcFkFields = mapping.getSourceRelationKeyFields();
  
!         for (int index = 0; index < srcFkFields.size(); index++) {
!             parentDBField = (DatabaseField) mapping.getSourceKeyFields().get(index);
!             dbField = resolveDatabaseField((DatabaseField) srcFkFields.get(index), parentDBField);
!             setFieldToRelationTable(dbField, tblDef);
!             setForeignKeyForRelationTable(dbField, parentDBField);
!         }
  
          //add target foreign key fields into the relation table
          Vector targFkFields = mapping.getTargetRelationKeyFields();
! 
!         for (int index = 0; index < targFkFields.size(); index++) {
!             parentDBField = (DatabaseField) mapping.getTargetKeyFields().get(index);
!             dbField = resolveDatabaseField((DatabaseField) targFkFields.get(index), parentDBField);
!             setFieldToRelationTable(dbField, tblDef);
!             setForeignKeyForRelationTable(dbField, parentDBField);
!         }
      }
  
!     private void setForeignKeyForRelationTable(final DatabaseField dbField, final DatabaseField parentDBField) {
!         FieldDefinition fldDef;
!         fldDef = getFieldDefFromDBField(dbField, false);
!         fldDef.setForeignKeyFieldName(parentDBField.getTable().getName() + "." + parentDBField.getName());
!         return;
      }
  
      /**
--- 301,345 ----
          //first create relation table
          TableDefinition tblDef = getTableDefFromDBTable(mapping.getRelationTable());
  
          //add source foreign key fields into the relation table
          Vector srcFkFields = mapping.getSourceRelationKeyFields();
+         Vector srcKeyFields = mapping.getSourceKeyFields();
  
!         buildRelationTableFields(tblDef, srcFkFields, srcKeyFields);
  
          //add target foreign key fields into the relation table
          Vector targFkFields = mapping.getTargetRelationKeyFields();
!         Vector targKeyFields = mapping.getTargetKeyFields();
!         
!         buildRelationTableFields(tblDef, targFkFields, targKeyFields);
      }
  
!     /**
!      * Build field definitions and foreign key constraints for all many-to-many relation table.
!      */
!     private void buildRelationTableFields(TableDefinition tblDef, Vector fkFields, Vector targetFields) {
!         assert fkFields.size() > 0 && fkFields.size() == targetFields.size();
!         
!         DatabaseField fkField = null;
!         DatabaseField targetField = null;
!         Vector<String> fkFieldNames = new Vector();
!         Vector<String> targetFieldNames = new Vector();
! 
!         for (int index = 0; index < fkFields.size(); index++) {
!             fkField = (DatabaseField) fkFields.get(index);
!             targetField = (DatabaseField) targetFields.get(index);
!             fkFieldNames.add(fkField.getName());
!             targetFieldNames.add(targetField.getName());
!             
!             fkField = resolveDatabaseField(fkField, targetField);
!             setFieldToRelationTable(fkField, tblDef);
!         }
!         
!         // add a foreign key constraint
!         DatabaseTable targetTable = targetField.getTable();
!         TableDefinition targetTblDef = getTableDefFromDBTable(targetTable);
!         
!         addForeignKeyConstraint(tblDef, targetTblDef, fkFieldNames, targetFieldNames);
      }
  
      /**
***************
*** 390,415 ****
      }    
  
      private void addForeignKeyFieldToFieldDefinition(final Map srcFields) {
          DatabaseField dbSrcField = null;
          DatabaseField dbTrgField = null;
          
          //add source foreign key fields into the table
          for (Iterator srcFkFields = srcFields.keySet().iterator(); srcFkFields.hasNext();) {            
              dbSrcField = (DatabaseField)srcFkFields.next();
              dbTrgField = (DatabaseField)srcFields.get(dbSrcField);
              
              FieldDefinition srcFldDef = (FieldDefinition)fieldMap.get(dbSrcField);
              FieldDefinition trgFldDef = (FieldDefinition)fieldMap.get(dbTrgField);
              
!             srcFldDef.setForeignKeyFieldName(
!                 dbTrgField.getTable().getQualifiedName() + "." + dbTrgField.getName());
!             
!             // Also ensure that the type, size and subsize of the foreign key field is 
!             // same as that of the original field.
!             srcFldDef.setType(trgFldDef.getType());
!             srcFldDef.setSize(trgFldDef.getSize()); 
!             srcFldDef.setSubSize(trgFldDef.getSubSize());            
          }        
      }
  
      /**
--- 403,443 ----
      }    
  
      private void addForeignKeyFieldToFieldDefinition(final Map srcFields) {
+         if(srcFields.size() == 0) {
+             return;
+         }
+         
          DatabaseField dbSrcField = null;
          DatabaseField dbTrgField = null;
          
          //add source foreign key fields into the table
+         Vector<String> fkFieldNames = new Vector();
+         Vector<String> targetFieldNames = new Vector();
          for (Iterator srcFkFields = srcFields.keySet().iterator(); srcFkFields.hasNext();) {            
              dbSrcField = (DatabaseField)srcFkFields.next();
              dbTrgField = (DatabaseField)srcFields.get(dbSrcField);
+             fkFieldNames.add(dbSrcField.getName());
+             targetFieldNames.add(dbTrgField.getName());
              
              FieldDefinition srcFldDef = (FieldDefinition)fieldMap.get(dbSrcField);
              FieldDefinition trgFldDef = (FieldDefinition)fieldMap.get(dbTrgField);
              
!             if(srcFldDef != null && trgFldDef != null) {
!                 // Also ensure that the type, size and subsize of the foreign key field is 
!                 // same as that of the original field.
!                 srcFldDef.setType(trgFldDef.getType());
!                 srcFldDef.setSize(trgFldDef.getSize()); 
!                 srcFldDef.setSubSize(trgFldDef.getSubSize());
!             }
          }        
+ 
+         // add a foreign key constraint
+         DatabaseTable sourceTable = dbSrcField.getTable();
+         DatabaseTable targetTable = dbTrgField.getTable();
+         TableDefinition sourceTableDef = getTableDefFromDBTable(sourceTable);
+         TableDefinition targetTableDef = getTableDefFromDBTable(targetTable);
+         
+         addForeignKeyConstraint(sourceTableDef, targetTableDef, fkFieldNames, targetFieldNames);
      }
  
      /**
***************
*** 439,444 ****
--- 467,475 ----
          DatabaseField reslovedDatabaseField = new DatabaseField();
          reslovedDatabaseField.setName(childField.getName());
          reslovedDatabaseField.setType(getFieldDefFromDBField(parentField, true).getType());
+         //Table should be set, otherwise other same name field will be used wrongly because equals() is true.
+         //Fix for GF#1392 the same name column for the entity and many-to-many table cause wrong pk constraint.
+         reslovedDatabaseField.setTable(childField.getTable());
  
          return reslovedDatabaseField;
      }
***************
*** 478,484 ****
                  }
  
                  if ((fieldType == null) || (!fieldType.isPrimitive() && 
!                         (new DatabaseSessionImpl(project).getPlatform().getFieldTypeDefinition(fieldType) == null))) {
                      //TODO: log a warning for inaccessiable type or not convertable type.
                      AbstractSessionLog.getLog().log(SessionLog.FINEST, "field_type_set_to_java_lang_string", dbField.getQualifiedName(), fieldType);
  
--- 509,515 ----
                  }
  
                  if ((fieldType == null) || (!fieldType.isPrimitive() && 
!                         (databasePlatform.getFieldTypeDefinition(fieldType) == null))) {
                      //TODO: log a warning for inaccessiable type or not convertable type.
                      AbstractSessionLog.getLog().log(SessionLog.FINEST, "field_type_set_to_java_lang_string", dbField.getQualifiedName(), fieldType);
  
***************
*** 531,553 ****
              dbTbl = (DatabaseTable) dbTblIter.next();
              Map srcFields = (HashMap)desc.getAdditionalTablePrimaryKeyFields().get(dbTbl);
              if (null != srcFields) {
!                 addJoinColumnsFkFieldToFieldDefinition(srcFields);
              }
          }              
      }    
     
!     private void addJoinColumnsFkFieldToFieldDefinition(final Map srcFields) {
!         DatabaseField dbSrcField = null;
!         DatabaseField dbTrgField = null;
          
          //add source foreign key fields into the table
!         for (Iterator srcFkFields = srcFields.keySet().iterator(); srcFkFields.hasNext();) {            
!             dbSrcField = (DatabaseField)srcFkFields.next();
!             dbTrgField = (DatabaseField)srcFields.get(dbSrcField);            
!             FieldDefinition srcFldDef = (FieldDefinition)fieldMap.get(dbSrcField);
!             FieldDefinition trgFldDef = (FieldDefinition)fieldMap.get(dbTrgField);            
!             trgFldDef.setForeignKeyFieldName(
!                 dbSrcField.getTable().getQualifiedName() + "." + dbSrcField.getName());
!         }        
      }
  }
--- 562,688 ----
              dbTbl = (DatabaseTable) dbTblIter.next();
              Map srcFields = (HashMap)desc.getAdditionalTablePrimaryKeyFields().get(dbTbl);
              if (null != srcFields) {
!                 addJoinColumnsFkConstraint(srcFields);
              }
          }              
      }    
     
!     private void addJoinColumnsFkConstraint(final Map srcFields) {
!         if(srcFields.size() == 0) {
!             return;
!         }
!         
!         DatabaseField fkField = null;
!         DatabaseField pkField = null;
!         Vector<String> fkFieldNames = new Vector();
!         Vector<String> pkFieldNames = new Vector();
          
          //add source foreign key fields into the table
!         for (Iterator srcPkFields = srcFields.keySet().iterator(); srcPkFields.hasNext();) {            
!             pkField = (DatabaseField)srcPkFields.next();
!             fkField = (DatabaseField)srcFields.get(pkField);
!             fkFieldNames.add(fkField.getName());
!             pkFieldNames.add(pkField.getName());
!         }
! 
!         // add a foreign key constraint
!         DatabaseTable sourceTable = fkField.getTable();
!         DatabaseTable targetTable = pkField.getTable();
!         TableDefinition sourceTableDef = getTableDefFromDBTable(sourceTable);
!         TableDefinition targetTableDef = getTableDefFromDBTable(targetTable);
!         
!         addForeignKeyConstraint(sourceTableDef, targetTableDef, fkFieldNames, pkFieldNames);
!     }
! 
!     /**
!      * Add a foreign key constraint to the source table.
!      */
!     private void addForeignKeyConstraint(TableDefinition sourceTableDef, TableDefinition targetTableDef, 
!                                          Vector<String> fkFields, Vector<String> targetFields) {
!         assert fkFields.size() > 0 && fkFields.size() == targetFields.size();
!         
!         // target keys could be primary keys or candidate(unique) keys of the target table
! 
!         Vector<String> fkFieldNames = fkFields;
!         Vector<String> targetFieldNames = targetFields;
!         
!         if (fkFields.size() > 1) {
!             // if composite key, we should consider the order of keys.
!             // Foreign Key constraint should follow the primary/unique key order of the target table.
!             // e.g. if the primary key constraint of the target table is (p2, p1),
!             // foreign key constraint should be "(f2, f1) REFERENCES TARGET (p2, p1)".
! 
!             // we try to reorder keys using primary keys or unique keys order of the target table,
!             // but if we might not resolve it due to incorrect field name, then let it as it is.
!             // This will trigger underlying database exception so users can recognize errors.
!             
!             boolean resolved = false;
!             boolean error = false;
!             
!             Map<String, String> targetToFkField = new HashMap<String, String>();
!             for (int index = 0; index < fkFields.size(); index++) {
!                 String targetField = targetFields.get(index);
!                 if (targetToFkField.containsKey(targetField)) {
!                     //target key column appears more than once
!                     error = true;
!                     break;
!                 }
!                 targetToFkField.put(targetField, fkFields.get(index));
!             }
! 
!             Vector<String> orderedFkFields = new Vector<String>(fkFields.size());
!             Vector<String> orderedTargetFields = new Vector<String>(targetFields.size());
! 
!             if (!error) {
!                 // if target fields are primary keys
!                 resolved = true;
!                 for (String pkField : (Vector<String>)targetTableDef.getPrimaryKeyFieldNames()) {
!                     String fkField = targetToFkField.get(pkField);
!                     if (fkField == null) {
!                         //primary key column not found
!                         resolved = false;
!                         break;
!                     }
!                     orderedFkFields.add(fkField);
!                     orderedTargetFields.add(pkField);
!                 }
!             }
!             
!             if (!error && !resolved) {
!                 // if target fields are unique keys
!                 for (Object uniqueConstraint : targetTableDef.getUniqueKeys()) {
!                     orderedFkFields.setSize(0);
!                     orderedTargetFields.setSize(0);
! 
!                     resolved = true;
!                     for (String ukField : (String[])uniqueConstraint) {
!                         String fkField = targetToFkField.get(ukField);
!                         if (fkField == null) {
!                             //unique key column not found
!                             resolved = false;
!                             break;
!                         }
!                         orderedFkFields.add(fkField);
!                         orderedTargetFields.add(ukField);
!                     }
!                     if (resolved) {
!                         break;
!                     }
!                 }
!             }
! 
!             if (resolved) {
!                 fkFieldNames = orderedFkFields;
!                 targetFieldNames = orderedTargetFields;
!             }
!         }
! 
!         // For bidirectional relationships both side of mapping will make the same FK constraint twice.
!         // TableDefinition.addForeignKeyConstraint() will ignore the same FK constraint.
! 
!         ForeignKeyConstraint fkc = sourceTableDef.buildForeignKeyConstraint(fkFieldNames, targetFieldNames,
!             targetTableDef, databasePlatform);
!         sourceTableDef.addForeignKeyConstraint(fkc);
      }
+     
  }
================================================================================
Merge Diffs: /ade/tware_toplink10i/tldev/source/essentials/oracle/toplink/essentials/tools/schemaframework/FieldDefinition.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1072_table_generation_wonsoek_kim_061107/ade_storage/000004/AB0952363AC40CBFE034080020E8C54E.7
Report generated at Tue Nov  7 11:21:53 2006
--------------------------------------------------------------------------------
*** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1072_table_generation_wonsoek_kim_061107/ade_storage/000004/AB0952363AC40CBFE034080020E8C54E.7	Mon Nov  6 14:28:29 2006
--- /ade/tware_toplink10i/tldev/source/essentials/oracle/toplink/essentials/tools/schemaframework/FieldDefinition.java	Tue Nov  7 10:57:21 2006
***************
*** 18,24 ****
   * own identifying information: Portions Copyright [yyyy] 
   * [name of copyright owner]
   */
! // Copyright (c) 1998, 2005, Oracle. All rights reserved.  
  package oracle.toplink.essentials.tools.schemaframework;
  
  import java.io.*;
--- 18,24 ----
   * own identifying information: Portions Copyright [yyyy] 
   * [name of copyright owner]
   */
! // Copyright (c) 1998, 2006, Oracle. All rights reserved.  
  package oracle.toplink.essentials.tools.schemaframework;
  
  import java.io.*;
***************
*** 50,56 ****
      protected boolean isUnique;
      protected String additional;
      protected String constraint;
!     protected String foreignKeyFieldName;
  
      public FieldDefinition() {
          this.name = "";
--- 50,57 ----
      protected boolean isUnique;
      protected String additional;
      protected String constraint;
!     // @deprecated Use ForeignKeyConstraint instead.
!     protected String foreignKeyFieldName; //fully-qualified foreign key field name
  
      public FieldDefinition() {
          this.name = "";
***************
*** 205,210 ****
--- 206,216 ----
          return constraint;
      }
  
+     /**
+      * PUBLIC:
+      * Return fully-qualified foreign key field name.
+      * @deprecated Use ForeignKeyConstraint instead.
+      */
      public String getForeignKeyFieldName() {
          return foreignKeyFieldName;
      }
***************
*** 296,301 ****
--- 302,314 ----
          constraint = string;
      }
  
+     /**
+      * PUBLIC:
+      * Set the foreign key field name. This value is used for a foreign key constraint.
+      * 
+      * @param foreignKeyFieldName fully-qualified field name
+      * @deprecated Use ForeignKeyConstraint instead.
+      */
      public void setForeignKeyFieldName(String foreignKeyFieldName) {
          this.foreignKeyFieldName = foreignKeyFieldName;
      }
================================================================================
Merge Diffs: /ade/tware_toplink10i/tldev/source/essentials/oracle/toplink/essentials/tools/schemaframework/ForeignKeyConstraint.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1072_table_generation_wonsoek_kim_061107/ade_storage/000005/AB0952363AC40CBFE034080020E8C54E.5
Report generated at Tue Nov  7 11:21:53 2006
--------------------------------------------------------------------------------
*** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1072_table_generation_wonsoek_kim_061107/ade_storage/000005/AB0952363AC40CBFE034080020E8C54E.5	Mon Nov  6 14:28:29 2006
--- /ade/tware_toplink10i/tldev/source/essentials/oracle/toplink/essentials/tools/schemaframework/ForeignKeyConstraint.java	Tue Nov  7 10:57:21 2006
***************
*** 18,24 ****
   * own identifying information: Portions Copyright [yyyy] 
   * [name of copyright owner]
   */
! // Copyright (c) 1998, 2005, Oracle. All rights reserved.  
  package oracle.toplink.essentials.tools.schemaframework;
  
  import java.io.*;
--- 18,24 ----
   * own identifying information: Portions Copyright [yyyy] 
   * [name of copyright owner]
   */
! // Copyright (c) 1998, 2006, Oracle. All rights reserved.  
  package oracle.toplink.essentials.tools.schemaframework;
  
  import java.io.*;
***************
*** 33,41 ****
   */
  public class ForeignKeyConstraint implements Serializable {
      protected String name;
!     protected Vector sourceFields;
!     protected Vector targetFields;
!     protected String targetTable;
      protected boolean shouldCascadeOnDelete;
  
      public ForeignKeyConstraint() {
--- 33,41 ----
   */
  public class ForeignKeyConstraint implements Serializable {
      protected String name;
!     protected Vector sourceFields; //source(foreign key) field names
!     protected Vector targetFields; //target(primary key) field names
!     protected String targetTable; //fully-qualified target table name
      protected boolean shouldCascadeOnDelete;
  
      public ForeignKeyConstraint() {
================================================================================
Merge Diffs: /ade/tware_toplink10i/tldev/source/essentials/oracle/toplink/essentials/tools/schemaframework/SchemaManager.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1072_table_generation_wonsoek_kim_061107/ade_storage/000006/AB0952363AC40CBFE034080020E8C54E.14
Report generated at Tue Nov  7 11:21:53 2006
--------------------------------------------------------------------------------
*** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1072_table_generation_wonsoek_kim_061107/ade_storage/000006/AB0952363AC40CBFE034080020E8C54E.14	Mon Nov  6 14:28:29 2006
--- /ade/tware_toplink10i/tldev/source/essentials/oracle/toplink/essentials/tools/schemaframework/SchemaManager.java	Tue Nov  7 10:57:21 2006
***************
*** 19,25 ****
   * [name of copyright owner]
   */
  
! // Copyright (c) 1998, 2006, Oracle. All rights reserved.  
  package oracle.toplink.essentials.tools.schemaframework;
  
  import java.io.Writer;
--- 19,25 ----
   * [name of copyright owner]
   */
  
! // Copyright (c) 1998, 2006, Oracle. All rights reserved.  
  package oracle.toplink.essentials.tools.schemaframework;
  
  import java.io.Writer;
***************
*** 55,61 ****
      protected DatabaseSessionImpl session;
      protected Writer createSchemaWriter;
      protected Writer dropSchemaWriter;
!     protected boolean createSQLFiles = true;
  
      public SchemaManager(DatabaseSessionImpl session) {
          this.session = session;
--- 55,61 ----
      protected DatabaseSessionImpl session;
      protected Writer createSchemaWriter;
      protected Writer dropSchemaWriter;
!     protected boolean createSQLFiles = true; //if true, schema writer will add terminator string.
  
      public SchemaManager(DatabaseSessionImpl session) {
          this.session = session;
***************
*** 112,120 ****
       */
      public void closeDDLWriter() {
          closeDDLWriter(createSchemaWriter);
!         if (null != dropSchemaWriter) {
!             closeDDLWriter(dropSchemaWriter);
!         }
      }
  
      public void closeDDLWriter(Writer schemaWriter) {
--- 112,120 ----
       */
      public void closeDDLWriter() {
          closeDDLWriter(createSchemaWriter);
!         closeDDLWriter(dropSchemaWriter);
!         createSchemaWriter = null;
!         dropSchemaWriter = null;
      }
  
      public void closeDDLWriter(Writer schemaWriter) {
***************
*** 125,131 ****
          try {
              schemaWriter.flush();
              schemaWriter.close();
-             schemaWriter = null;
          } catch (java.io.IOException ioException) {
              throw ValidationException.fileError(ioException);
          }
--- 125,130 ----
***************
*** 143,148 ****
--- 142,165 ----
              tableDefinition.createConstraints(getSession(), createSchemaWriter);
          }
      }
+     
+     void createUniqueConstraints(TableDefinition tableDefinition) throws TopLinkException {
+         if (shouldWriteToDatabase()) {
+             tableDefinition.createUniqueConstraintsOnDatabase(getSession());
+         } else {
+             tableDefinition.setCreateSQLFiles(createSQLFiles);
+             tableDefinition.createUniqueConstraints(getSession(), createSchemaWriter);
+         }
+     }
+     
+     void createForeignConstraints(TableDefinition tableDefinition) throws TopLinkException {
+         if (shouldWriteToDatabase()) {
+             tableDefinition.createForeignConstraintsOnDatabase(getSession());
+         } else {
+             tableDefinition.setCreateSQLFiles(createSQLFiles);
+             tableDefinition.createForeignConstraints(getSession(), createSchemaWriter);
+         }
+     }
  
      /**
       * Use the definition object to create the schema entity on the database.
================================================================================
Merge Diffs: /ade/tware_toplink10i/tldev/source/essentials/oracle/toplink/essentials/tools/schemaframework/TableCreator.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1072_table_generation_wonsoek_kim_061107/ade_storage/000007/AB0952363AC40CBFE034080020E8C54E.5
Report generated at Tue Nov  7 11:21:53 2006
--------------------------------------------------------------------------------
*** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1072_table_generation_wonsoek_kim_061107/ade_storage/000007/AB0952363AC40CBFE034080020E8C54E.5	Mon Nov  6 14:28:29 2006
--- /ade/tware_toplink10i/tldev/source/essentials/oracle/toplink/essentials/tools/schemaframework/TableCreator.java	Tue Nov  7 10:57:21 2006
***************
*** 18,24 ****
   * own identifying information: Portions Copyright [yyyy] 
   * [name of copyright owner]
   */
! // Copyright (c) 1998, 2005, Oracle. All rights reserved.  
  package oracle.toplink.essentials.tools.schemaframework;
  
  import java.util.*;
--- 18,24 ----
   * own identifying information: Portions Copyright [yyyy] 
   * [name of copyright owner]
   */
! // Copyright (c) 1998, 2006, Oracle. All rights reserved.  
  package oracle.toplink.essentials.tools.schemaframework;
  
  import java.util.*;
***************
*** 75,82 ****
              schemaManager.buildFieldTypes((TableDefinition)enumtr.nextElement());
          }
  
          for (Enumeration enumtr = getTableDefinitions().elements(); enumtr.hasMoreElements();) {
!             schemaManager.createConstraints((TableDefinition)enumtr.nextElement());
          }
      }
  
--- 75,88 ----
              schemaManager.buildFieldTypes((TableDefinition)enumtr.nextElement());
          }
  
+         // Unique constraints should be generated before foreign key constraints,
+         // because foreign key constraints can reference unique constraints
          for (Enumeration enumtr = getTableDefinitions().elements(); enumtr.hasMoreElements();) {
!             schemaManager.createUniqueConstraints((TableDefinition)enumtr.nextElement());
!         }
!         
!         for (Enumeration enumtr = getTableDefinitions().elements(); enumtr.hasMoreElements();) {
!             schemaManager.createForeignConstraints((TableDefinition)enumtr.nextElement());
          }
      }
  
***************
*** 107,114 ****
              }
          }
  
          for (Enumeration enumtr = getTableDefinitions().elements(); enumtr.hasMoreElements();) {
!             schemaManager.createConstraints((TableDefinition)enumtr.nextElement());
          }
  
          schemaManager.createSequences();
--- 113,126 ----
              }
          }
  
+         // Unique constraints should be generated before foreign key constraints,
+         // because foreign key constraints can reference unique constraints
          for (Enumeration enumtr = getTableDefinitions().elements(); enumtr.hasMoreElements();) {
!             schemaManager.createUniqueConstraints((TableDefinition)enumtr.nextElement());
!         }
!         
!         for (Enumeration enumtr = getTableDefinitions().elements(); enumtr.hasMoreElements();) {
!             schemaManager.createForeignConstraints((TableDefinition)enumtr.nextElement());
          }
  
          schemaManager.createSequences();
***************
*** 252,259 ****
              }
          }
  
          for (Enumeration enumtr = getTableDefinitions().elements(); enumtr.hasMoreElements();) {
!             schemaManager.createConstraints((TableDefinition)enumtr.nextElement());
          }
      }
  
--- 264,277 ----
              }
          }
  
+         // Unique constraints should be generated before foreign key constraints,
+         // because foreign key constraints can reference unique constraints
+         for (Enumeration enumtr = getTableDefinitions().elements(); enumtr.hasMoreElements();) {
+             schemaManager.createUniqueConstraints((TableDefinition)enumtr.nextElement());
+         }
+         
          for (Enumeration enumtr = getTableDefinitions().elements(); enumtr.hasMoreElements();) {
!             schemaManager.createForeignConstraints((TableDefinition)enumtr.nextElement());
          }
      }
  
================================================================================
Merge Diffs: /ade/tware_toplink10i/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/tests/cmp3/ddlgeneration/DDLGenerationJUnitTestSuite.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1072_table_generation_wonsoek_kim_061107/ade_storage/000010/AB0952363AC40CBFE034080020E8C54E.0
Report generated at Tue Nov  7 11:21:53 2006
--------------------------------------------------------------------------------
*** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1072_table_generation_wonsoek_kim_061107/ade_storage/000010/AB0952363AC40CBFE034080020E8C54E.0	Tue Nov  7 10:55:25 2006
--- /ade/tware_toplink10i/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/tests/cmp3/ddlgeneration/DDLGenerationJUnitTestSuite.java	Tue Nov  7 10:55:25 2006
***************
*** 0 ****
--- 1,150 ----
+ package oracle.toplink.essentials.testing.tests.cmp3.ddlgeneration;
+ 
+ import junit.extensions.TestSetup;
+ import junit.framework.Test;
+ import junit.framework.TestSuite;
+ import oracle.toplink.essentials.testing.framework.junit.JUnitTestCase;
+ import oracle.toplink.essentials.testing.models.cmp3.ddlgeneration.CKeyEntityA;
+ import oracle.toplink.essentials.testing.models.cmp3.ddlgeneration.CKeyEntityAPK;
+ import oracle.toplink.essentials.testing.models.cmp3.ddlgeneration.CKeyEntityB;
+ import oracle.toplink.essentials.testing.models.cmp3.ddlgeneration.CKeyEntityBPK;
+ import oracle.toplink.essentials.testing.models.cmp3.ddlgeneration.CKeyEntityC;
+ import oracle.toplink.essentials.testing.models.cmp3.ddlgeneration.CKeyEntityCPK;
+ 
+ import javax.persistence.EntityManager;
+ import java.util.HashMap;
+ import java.util.Map;
+ 
+ /**
+  * JUnit test case(s) for DDL generation.
+  */
+ public class DDLGenerationJUnitTestSuite extends JUnitTestCase {
+ 
+     public DDLGenerationJUnitTestSuite() {
+         super();
+     }
+ 
+     public DDLGenerationJUnitTestSuite(String name) {
+         super(name);
+     }
+ 
+     public static Test suite() {
+         TestSuite suite = new TestSuite(DDLGenerationJUnitTestSuite.class);
+ 
+         return new TestSetup(suite) {
+ 
+             protected void setUp() {
+                 // Trigger DDL generation
+                 //TODO: Let's add a flag which do not disregard DDL generation errors.
+                 //TODO: This is required to ensure that DDL generation has succeeded.
+                 EntityManager em = createEntityManager("ddlGeneration");
+                 em.close();
+             }
+ 
+             protected void tearDown() {
+                 clearCache("ddlGeneration");
+             }
+         };
+     }
+ 
+     // Test for GF#1392
+     // If there is a same name column for the entity and many-to-many table, wrong pk constraint generated.
+     public void testDDLPkConstraintErrorIncludingRelationTableColumnName() {
+         EntityManager em = createEntityManager("ddlGeneration");
+         em.getTransaction().begin();
+         try {
+ 
+             CKeyEntityC c = new CKeyEntityC(new CKeyEntityCPK("Manager"));
+             em.persist(c);
+ 
+             em.getTransaction().commit();
+         } catch (RuntimeException e) {
+             if (em.getTransaction().isActive())
+                 em.getTransaction().rollback();
+             fail("DDL generation may generate wrong Primary Key constraint, thrown:" + e);
+         } finally {
+             em.close();
+         }
+     }
+ 
+     // Test for relationships using candidate(unique) keys
+     public void testDDLUniqueKeysAsJoinColumns() {
+         CKeyEntityAPK aKey;
+         CKeyEntityBPK bKey;
+         
+         EntityManager em = createEntityManager("ddlGeneration");
+         em.getTransaction().begin();
+         try {
+             CKeyEntityA a = new CKeyEntityA("Wonseok", "Kim");
+             CKeyEntityB b = new CKeyEntityB("B1209");
+             //set unique keys
+             b.setUnq1("u0001");
+             b.setUnq2("u0002");
+ 
+             a.setUniqueB(b);
+             b.setUniqueA(a);
+             
+             em.persist(a);
+             em.persist(b);
+ 
+             em.getTransaction().commit();
+             
+             aKey = a.getKey();
+             bKey = b.getKey();
+         } catch (RuntimeException e) {
+             if (em.getTransaction().isActive())
+                 em.getTransaction().rollback();
+             throw e;
+         } finally {
+             em.close();
+         }
+         //clearCache("ddlGeneration");
+ 
+         em = createEntityManager("ddlGeneration");
+         em.getTransaction().begin();
+         try {
+             CKeyEntityA a = em.find(CKeyEntityA.class, aKey);
+             assertNotNull(a);
+ 
+             CKeyEntityB b = a.getUniqueB();
+             assertNotNull(b);
+ 
+             assertEquals(b.getUnq1(), "u0001");
+             assertEquals(b.getUnq2(), "u0002");
+ 
+             em.getTransaction().commit();
+         } catch (RuntimeException e) {
+             if (em.getTransaction().isActive())
+                 em.getTransaction().rollback();
+             throw e;
+         } finally {
+             em.close();
+         }
+         //clearCache("ddlGeneration");
+ 
+         em = createEntityManager("ddlGeneration");
+         em.getTransaction().begin();
+         try {
+ 
+             CKeyEntityB b = em.find(CKeyEntityB.class, bKey);
+             assertNotNull(b);
+ 
+             CKeyEntityA a = b.getUniqueA();
+             assertNotNull(a);
+             assertEquals(a.getKey(), aKey);
+ 
+             em.getTransaction().commit();
+         } catch (RuntimeException e) {
+             if (em.getTransaction().isActive())
+                 em.getTransaction().rollback();
+             throw e;
+         } finally {
+             em.close();
+         }
+ 
+     }
+ 
+     public static void main(String[] args) {
+         junit.textui.TestRunner.run(suite());
+     }
+ }
================================================================================
Merge Diffs: /ade/tware_toplink10i/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/models/cmp3/ddlgeneration/CKeyEntityA.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1072_table_generation_wonsoek_kim_061107/ade_storage/000013/AB0952363AC40CBFE034080020E8C54E.0
Report generated at Tue Nov  7 11:21:53 2006
--------------------------------------------------------------------------------
*** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1072_table_generation_wonsoek_kim_061107/ade_storage/000013/AB0952363AC40CBFE034080020E8C54E.0	Tue Nov  7 10:55:29 2006
--- /ade/tware_toplink10i/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/models/cmp3/ddlgeneration/CKeyEntityA.java	Tue Nov  7 10:55:28 2006
***************
*** 0 ****
--- 1,114 ----
+ package oracle.toplink.essentials.testing.models.cmp3.ddlgeneration;
+ 
+ import javax.persistence.Column;
+ import javax.persistence.Entity;
+ import javax.persistence.GeneratedValue;
+ import static javax.persistence.GenerationType.TABLE;
+ import javax.persistence.Id;
+ import javax.persistence.IdClass;
+ import javax.persistence.JoinColumn;
+ import javax.persistence.JoinColumns;
+ import javax.persistence.ManyToOne;
+ import javax.persistence.OneToOne;
+ import javax.persistence.Table;
+ import javax.persistence.TableGenerator;
+ import java.util.Collection;
+ 
+ /**
+  * Composite key Entity.
+  * 
+  * @author Wonseok Kim
+  */
+ @Entity
+ @IdClass(CKeyEntityAPK.class)
+ @Table(name = "DDL_CKENTA")
+ @TableGenerator(
+     name = "CKEYENTITY_TABLE_GENERATOR",
+     table = "DDL_CKENT_SEQ",
+     pkColumnName = "SEQ_NAME",
+     valueColumnName = "SEQ_COUNT",
+     pkColumnValue = "CKENT_SEQ"
+ )
+ public class CKeyEntityA {
+     @Id
+     @GeneratedValue(strategy = TABLE, generator = "CKEYENTITY_TABLE_GENERATOR")
+     @Column(name = "SEQ")
+     private int seq;
+ 
+     @Id
+     @Column(name = "F_NAME")
+     private String firstName;
+ 
+     @Id
+     @Column(name = "L_NAME")
+     private String lastName;
+ 
+     @ManyToOne
+     @JoinColumns({
+         @JoinColumn(name="B_SEQ", referencedColumnName = "SEQ"),
+         @JoinColumn(name="B_CODE", referencedColumnName = "CODE")
+     })
+     private Collection<CKeyEntityB> bs;
+     
+     @OneToOne(mappedBy="a")
+     private CKeyEntityC c;
+     
+     // Relationship using candidate(unique) keys
+     // For testing whether a generated FK constraint has reordered unique keys according to target table.
+     // CKeyEntityB has unique constraint ("UNQ2", "UNQ1").
+     @OneToOne
+     @JoinColumns({
+         @JoinColumn(name="B_UNQ1", referencedColumnName = "UNQ1"),
+         @JoinColumn(name="B_UNQ2", referencedColumnName = "UNQ2")
+     })
+     private CKeyEntityB uniqueB;
+     
+ 
+     public CKeyEntityA() {
+     }
+ 
+     public CKeyEntityA(String firstName, String lastName) {
+         this.firstName = firstName;
+         this.lastName = lastName;
+     }
+ 
+     public int getSeq() {
+         return seq;
+     }
+ 
+     public String getFirstName() {
+         return firstName;
+     }
+ 
+     public String getLastName() {
+         return lastName;
+     }
+ 
+     public CKeyEntityAPK getKey() {
+         return new CKeyEntityAPK(seq, firstName, lastName);
+     }
+     
+     public Collection<CKeyEntityB> getBs() {
+         return bs;
+     }
+ 
+     public void setBs(Collection<CKeyEntityB> bs) {
+         this.bs = bs;
+     }
+ 
+     public CKeyEntityC getC() {
+         return c;
+     }
+ 
+     public void setC(CKeyEntityC c) {
+         this.c = c;
+     }
+ 
+     public CKeyEntityB getUniqueB() {
+         return uniqueB;
+     }
+ 
+     public void setUniqueB(CKeyEntityB uniqueB) {
+         this.uniqueB = uniqueB;
+     }
+ }
================================================================================
Merge Diffs: /ade/tware_toplink10i/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/models/cmp3/ddlgeneration/CKeyEntityAPK.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1072_table_generation_wonsoek_kim_061107/ade_storage/000014/AB0952363AC40CBFE034080020E8C54E.0
Report generated at Tue Nov  7 11:21:53 2006
--------------------------------------------------------------------------------
*** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1072_table_generation_wonsoek_kim_061107/ade_storage/000014/AB0952363AC40CBFE034080020E8C54E.0	Tue Nov  7 10:55:32 2006
--- /ade/tware_toplink10i/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/models/cmp3/ddlgeneration/CKeyEntityAPK.java	Tue Nov  7 10:55:32 2006
***************
*** 0 ****
--- 1,37 ----
+ package oracle.toplink.essentials.testing.models.cmp3.ddlgeneration;
+ 
+ /**
+  * @author Wonseok Kim
+  */
+ public class CKeyEntityAPK {
+     public int seq;
+     public String firstName;
+     public String lastName;
+ 
+ 
+     public CKeyEntityAPK() {
+     }
+ 
+     public CKeyEntityAPK(int seq, String firstName, String lastName) {
+         this.seq = seq;
+         this.firstName = firstName;
+         this.lastName = lastName;
+     }
+ 
+     public boolean equals(Object o) {
+         if (this == o) return true;
+         if (o == null || getClass() != o.getClass()) return false;
+ 
+         CKeyEntityAPK that = (CKeyEntityAPK) o;
+ 
+         return seq == that.seq && firstName.equals(that.firstName) && lastName.equals(that.lastName);
+     }
+ 
+     public int hashCode() {
+         int result;
+         result = seq;
+         result = 31 * result + firstName.hashCode();
+         result = 31 * result + lastName.hashCode();
+         return result;
+     }
+ }
================================================================================
Merge Diffs: /ade/tware_toplink10i/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/models/cmp3/ddlgeneration/CKeyEntityB.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1072_table_generation_wonsoek_kim_061107/ade_storage/000015/AB0952363AC40CBFE034080020E8C54E.0
Report generated at Tue Nov  7 11:21:53 2006
--------------------------------------------------------------------------------
*** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1072_table_generation_wonsoek_kim_061107/ade_storage/000015/AB0952363AC40CBFE034080020E8C54E.0	Tue Nov  7 10:55:36 2006
--- /ade/tware_toplink10i/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/models/cmp3/ddlgeneration/CKeyEntityB.java	Tue Nov  7 10:55:35 2006
***************
*** 0 ****
--- 1,114 ----
+ package oracle.toplink.essentials.testing.models.cmp3.ddlgeneration;
+ 
+ import javax.persistence.Column;
+ import javax.persistence.Entity;
+ import javax.persistence.GeneratedValue;
+ import static javax.persistence.GenerationType.TABLE;
+ import javax.persistence.Id;
+ import javax.persistence.IdClass;
+ import javax.persistence.Inheritance;
+ import javax.persistence.InheritanceType;
+ import javax.persistence.ManyToMany;
+ import javax.persistence.OneToMany;
+ import javax.persistence.OneToOne;
+ import javax.persistence.Table;
+ import javax.persistence.UniqueConstraint;
+ import java.util.Collection;
+ 
+ /**
+  * Composite Key Entity.
+  * 
+  * @author Wonseok Kim
+  */
+ @Entity
+ @IdClass(CKeyEntityBPK.class)
+ @Inheritance(strategy = InheritanceType.JOINED)
+ @Table(name = "DDL_CKENTB", 
+     uniqueConstraints = { 
+         @UniqueConstraint(columnNames={"UNQ2, UNQ1"}) //The order of columns shoud not be changed. See CKeyEntityA. 
+ })
+ public class CKeyEntityB {
+     @Id
+     @GeneratedValue(strategy = TABLE, generator = "CKEYENTITY_TABLE_GENERATOR")
+     @Column(name = "SEQ")
+     private int seq;
+ 
+     @Id
+     @Column(name = "CODE")
+     private String code;
+     
+     @Column(name = "UNQ1", nullable = false)
+     private String unq1;
+ 
+     @Column(name = "UNQ2", nullable = false)
+     private String unq2;
+     
+ 
+     @OneToMany(mappedBy="bs")
+     private Collection<CKeyEntityA> as;
+     
+     @ManyToMany(mappedBy="bs")
+     private Collection<CKeyEntityC> cs;
+ 
+     @OneToOne(mappedBy="uniqueB")
+     private CKeyEntityA uniqueA;
+ 
+     public CKeyEntityB() {
+     }
+ 
+     public CKeyEntityB(String code) {
+         this.code = code;
+     }
+ 
+     public int getSeq() {
+         return seq;
+     }
+ 
+     public String getCode() {
+         return code;
+     }
+ 
+     public CKeyEntityBPK getKey() {
+         return new CKeyEntityBPK(seq, code);
+     }
+     
+     public String getUnq1() {
+         return unq1;
+     }
+ 
+     public void setUnq1(String unq1) {
+         this.unq1 = unq1;
+     }
+ 
+     public String getUnq2() {
+         return unq2;
+     }
+ 
+     public void setUnq2(String unq2) {
+         this.unq2 = unq2;
+     }
+ 
+     public Collection<CKeyEntityA> getAs() {
+         return as;
+     }
+ 
+     public void setAs(Collection<CKeyEntityA> as) {
+         this.as = as;
+     }
+ 
+     public Collection<CKeyEntityC> getCs() {
+         return cs;
+     }
+ 
+     public void setCs(Collection<CKeyEntityC> cs) {
+         this.cs = cs;
+     }
+ 
+     public CKeyEntityA getUniqueA() {
+         return uniqueA;
+     }
+ 
+     public void setUniqueA(CKeyEntityA uniqueA) {
+         this.uniqueA = uniqueA;
+     }
+ }
================================================================================
Merge Diffs: /ade/tware_toplink10i/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/models/cmp3/ddlgeneration/CKeyEntityB2.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1072_table_generation_wonsoek_kim_061107/ade_storage/000016/AB0952363AC40CBFE034080020E8C54E.0
Report generated at Tue Nov  7 11:21:53 2006
--------------------------------------------------------------------------------
*** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1072_table_generation_wonsoek_kim_061107/ade_storage/000016/AB0952363AC40CBFE034080020E8C54E.0	Tue Nov  7 10:55:40 2006
--- /ade/tware_toplink10i/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/models/cmp3/ddlgeneration/CKeyEntityB2.java	Tue Nov  7 10:55:39 2006
***************
*** 0 ****
--- 1,19 ----
+ package oracle.toplink.essentials.testing.models.cmp3.ddlgeneration;
+ 
+ import javax.persistence.Entity;
+ import javax.persistence.PrimaryKeyJoinColumn;
+ import javax.persistence.PrimaryKeyJoinColumns;
+ import javax.persistence.Table;
+ 
+ /**
+  * @author Wonseok Kim
+  */
+ @Entity
+ @Table(name="DDL_CKEYENTB2")
+ @PrimaryKeyJoinColumns({
+     @PrimaryKeyJoinColumn(name="SEQ", referencedColumnName="SEQ"),
+     @PrimaryKeyJoinColumn(name="CODE", referencedColumnName="CODE")
+ })
+ public class CKeyEntityB2 extends CKeyEntityB {
+     
+ }
================================================================================
Merge Diffs: /ade/tware_toplink10i/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/models/cmp3/ddlgeneration/CKeyEntityBPK.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1072_table_generation_wonsoek_kim_061107/ade_storage/000017/AB0952363AC40CBFE034080020E8C54E.0
Report generated at Tue Nov  7 11:21:53 2006
--------------------------------------------------------------------------------
*** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1072_table_generation_wonsoek_kim_061107/ade_storage/000017/AB0952363AC40CBFE034080020E8C54E.0	Tue Nov  7 10:55:44 2006
--- /ade/tware_toplink10i/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/models/cmp3/ddlgeneration/CKeyEntityBPK.java	Tue Nov  7 10:55:43 2006
***************
*** 0 ****
--- 1,33 ----
+ package oracle.toplink.essentials.testing.models.cmp3.ddlgeneration;
+ 
+ /**
+  * @author Wonseok Kim
+  */
+ public class CKeyEntityBPK {
+     public int seq;
+     public String code;
+ 
+     public CKeyEntityBPK() {
+     }
+ 
+     public CKeyEntityBPK(int seq, String code) {
+         this.seq = seq;
+         this.code = code;
+     }
+ 
+     public boolean equals(Object o) {
+         if (this == o) return true;
+         if (o == null || getClass() != o.getClass()) return false;
+ 
+         CKeyEntityBPK that = (CKeyEntityBPK) o;
+ 
+         return seq == that.seq && code.equals(that.code);
+     }
+ 
+     public int hashCode() {
+         int result;
+         result = seq;
+         result = 31 * result + (code != null ? code.hashCode() : 0);
+         return result;
+     }
+ }
================================================================================
Merge Diffs: /ade/tware_toplink10i/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/models/cmp3/ddlgeneration/CKeyEntityC.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1072_table_generation_wonsoek_kim_061107/ade_storage/000018/AB0952363AC40CBFE034080020E8C54E.0
Report generated at Tue Nov  7 11:21:53 2006
--------------------------------------------------------------------------------
*** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1072_table_generation_wonsoek_kim_061107/ade_storage/000018/AB0952363AC40CBFE034080020E8C54E.0	Tue Nov  7 10:55:48 2006
--- /ade/tware_toplink10i/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/models/cmp3/ddlgeneration/CKeyEntityC.java	Tue Nov  7 10:55:47 2006
***************
*** 0 ****
--- 1,87 ----
+ package oracle.toplink.essentials.testing.models.cmp3.ddlgeneration;
+ 
+ import javax.persistence.Column;
+ import javax.persistence.EmbeddedId;
+ import javax.persistence.Entity;
+ import javax.persistence.JoinColumn;
+ import javax.persistence.JoinColumns;
+ import javax.persistence.JoinTable;
+ import javax.persistence.ManyToMany;
+ import javax.persistence.OneToOne;
+ import javax.persistence.Table;
+ import java.util.Collection;
+ 
+ /**
+  * Composite Key Entity.
+  * 
+  * @author Wonseok Kim
+  */
+ @Entity
+ @Table(name = "DDL_CKENTC")
+ public class CKeyEntityC {
+ 
+     @EmbeddedId
+     private CKeyEntityCPK key;
+     
+     // Test for GF#1392
+     // If there is a same name column for the entity and many-to-many table, wrong pk constraint generated.
+     @Column(name="C_ROLE")
+     private String tempRole;
+ 
+     @OneToOne
+     @JoinColumns({
+         @JoinColumn(name="A_SEQ", referencedColumnName = "SEQ"),
+         @JoinColumn(name="A_L_NAME", referencedColumnName = "L_NAME"),
+         @JoinColumn(name="A_F_NAME", referencedColumnName = "F_NAME")
+     })
+     private CKeyEntityA a;
+     
+     @ManyToMany
+         @JoinTable(name="DDL_CKENT_C_B",
+         joinColumns={
+             @JoinColumn(name="C_SEQ", referencedColumnName="SEQ"),
+             @JoinColumn(name="C_ROLE", referencedColumnName="ROLE")
+         },
+         inverseJoinColumns={
+             @JoinColumn(name="B_SEQ", referencedColumnName = "SEQ"),
+             @JoinColumn(name="B_CODE", referencedColumnName = "CODE")
+         }
+     )
+     private Collection<CKeyEntityB> bs;
+ 
+ 
+     public CKeyEntityC() {
+     }
+ 
+     public CKeyEntityC(CKeyEntityCPK key) {
+         this.key = key;
+     }
+ 
+     public CKeyEntityCPK getKey() {
+         return key;
+     }
+ 
+     public String getTempRole() {
+         return tempRole;
+     }
+ 
+     public void setTempRole(String tempRole) {
+         this.tempRole = tempRole;
+     }
+ 
+     public CKeyEntityA getA() {
+         return a;
+     }
+ 
+     public void setA(CKeyEntityA a) {
+         this.a = a;
+     }
+ 
+     public Collection<CKeyEntityB> getBs() {
+         return bs;
+     }
+ 
+     public void setBs(Collection<CKeyEntityB> bs) {
+         this.bs = bs;
+     }
+ }
================================================================================
Merge Diffs: /ade/tware_toplink10i/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/models/cmp3/ddlgeneration/CKeyEntityCPK.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1072_table_generation_wonsoek_kim_061107/ade_storage/000019/AB0952363AC40CBFE034080020E8C54E.0
Report generated at Tue Nov  7 11:21:53 2006
--------------------------------------------------------------------------------
*** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1072_table_generation_wonsoek_kim_061107/ade_storage/000019/AB0952363AC40CBFE034080020E8C54E.0	Tue Nov  7 10:55:52 2006
--- /ade/tware_toplink10i/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/models/cmp3/ddlgeneration/CKeyEntityCPK.java	Tue Nov  7 10:55:51 2006
***************
*** 0 ****
--- 1,43 ----
+ package oracle.toplink.essentials.testing.models.cmp3.ddlgeneration;
+ 
+ import javax.persistence.Column;
+ import javax.persistence.Embeddable;
+ import javax.persistence.GeneratedValue;
+ import static javax.persistence.GenerationType.TABLE;
+ 
+ /**
+  * @author Wonseok Kim
+  */
+ @Embeddable
+ public class CKeyEntityCPK {
+     @GeneratedValue(strategy = TABLE, generator = "CKEYENTITY_TABLE_GENERATOR")
+     @Column(name = "SEQ")
+     public int seq;
+ 
+     @Column(name = "ROLE")
+     public String role;
+ 
+ 
+     public CKeyEntityCPK() {
+     }
+ 
+     public CKeyEntityCPK(String role) {
+         this.role = role;
+     }
+ 
+     public boolean equals(Object o) {
+         if (this == o) return true;
+         if (o == null || getClass() != o.getClass()) return false;
+ 
+         CKeyEntityCPK that = (CKeyEntityCPK) o;
+ 
+         return seq == that.seq && role.equals(that.role);
+     }
+ 
+     public int hashCode() {
+         int result;
+         result = seq;
+         result = 31 * result + role.hashCode();
+         return result;
+     }
+ }
================================================================================
Merge Diffs: /ade/tware_toplink10i/tltest/resource/essentials/ddl-generation-testmodel/META-INF/persistence.xml vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1072_table_generation_wonsoek_kim_061107/ade_storage/000020/AB0952363AC40CBFE034080020E8C54E.3
Report generated at Tue Nov  7 11:21:53 2006
--------------------------------------------------------------------------------
*** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1072_table_generation_wonsoek_kim_061107/ade_storage/000020/AB0952363AC40CBFE034080020E8C54E.3	Tue Nov  7 09:11:29 2006
--- /ade/tware_toplink10i/tltest/resource/essentials/ddl-generation-testmodel/META-INF/persistence.xml	Tue Nov  7 10:57:21 2006
***************
*** 11,16 ****
--- 11,17 ----
          <mapping-file>META-INF/merge-inherited-beers.xml</mapping-file>
          <mapping-file>META-INF/merge-inherited-consumer.xml</mapping-file>
          <mapping-file>META-INF/merge-inherited-certification.xml</mapping-file>
+         <mapping-file>META-INF/ddl-generation-model.xml</mapping-file>
          <class>oracle.toplink.essentials.testing.models.cmp3.xml.merge.inherited.EmbeddedSerialNumber</class>
          <properties>
              <property name="toplink.session-name" value="mergeinherited-session"/>
***************
*** 24,40 ****
              <property name="toplink.jdbc.read-connections.min" value="3"/>
              <property name="toplink.jdbc.read-connections.max" value="3"/>
              <property name="toplink.cache.size.default" value="500"/>
-             <property name="toplink.cache.size.Employee" value="550"/>
-             <property name="toplink.cache.size.oracle.toplink.essentials.testing.models.cmp3.advanced.Address" value="555"/>
              <property name="toplink.cache.type.default" value="Full"/>
-             <property name="toplink.cache.type.Employee" value="Weak"/>
-             <property name="toplink.cache.type.oracle.toplink.essentials.testing.models.cmp3.advanced.Address" value="HardWeak"/>
              <property name="toplink.session.customizer" value="oracle.toplink.essentials.testing.models.cmp3.advanced.Customizer"/>
-             <property name="toplink.descriptor.customizer.Employee" value="oracle.toplink.essentials.testing.models.cmp3.advanced.Customizer"/>
-             <property name="toplink.descriptor.customizer.oracle.toplink.essentials.testing.models.cmp3.advanced.Address" value="oracle.toplink.essentials.testing.models.cmp3.advanced.Customizer"/>
              <!--property name="toplink.logging.level" value="FINEST"/-->
              <property name="toplink.orm.throw.exceptions" value="true"/>
              <property name="toplink.ddl-generation" value="drop-and-create-tables"/>
          </properties>
      </persistence-unit>
  </persistence>
--- 25,37 ----
              <property name="toplink.jdbc.read-connections.min" value="3"/>
              <property name="toplink.jdbc.read-connections.max" value="3"/>
              <property name="toplink.cache.size.default" value="500"/>
              <property name="toplink.cache.type.default" value="Full"/>
              <property name="toplink.session.customizer" value="oracle.toplink.essentials.testing.models.cmp3.advanced.Customizer"/>
              <!--property name="toplink.logging.level" value="FINEST"/-->
              <property name="toplink.orm.throw.exceptions" value="true"/>
              <property name="toplink.ddl-generation" value="drop-and-create-tables"/>
+             <property name="toplink.create-ddl-jdbc-file-name" value="createDDL_ddlGeneration.jdbc"/>
+             <property name="toplink.drop-ddl-jdbc-file-name" value="dropDDL_ddlGeneration.jdbc"/>
          </properties>
      </persistence-unit>
  </persistence>
================================================================================
Merge Diffs: /ade/tware_toplink10i/tltest/resource/essentials/ddl-generation-testmodel/META-INF/ddl-generation-model.xml vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1072_table_generation_wonsoek_kim_061107/ade_storage/000022/AB0952363AC40CBFE034080020E8C54E.0
Report generated at Tue Nov  7 11:21:53 2006
--------------------------------------------------------------------------------
*** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1072_table_generation_wonsoek_kim_061107/ade_storage/000022/AB0952363AC40CBFE034080020E8C54E.0	Tue Nov  7 10:56:01 2006
--- /ade/tware_toplink10i/tltest/resource/essentials/ddl-generation-testmodel/META-INF/ddl-generation-model.xml	Tue Nov  7 10:56:00 2006
***************
*** 0 ****
--- 1,10 ----
+ <?xml version="1.0" encoding="UTF-8"?>
+ <entity-mappings version="1.0" xmlns="http://java.sun.com/xml/ns/persistence/orm" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm orm_1_0.xsd">
+     <package>oracle.toplink.essentials.testing.models.cmp3.ddlgeneration</package>
+ 
+     <entity class="CKeyEntityA"/>
+     <entity class="CKeyEntityB"/>
+     <entity class="CKeyEntityB2"/>
+     <entity class="CKeyEntityC"/>
+     
+ </entity-mappings>
================================================================================
Merge Diffs: /ade/tware_toplink10i/tltest/build.xml vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1072_table_generation_wonsoek_kim_061107/ade_storage/000023/AB0952363AC40CBFE034080020E8C54E.42
Report generated at Tue Nov  7 11:21:53 2006
--------------------------------------------------------------------------------
*** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1072_table_generation_wonsoek_kim_061107/ade_storage/000023/AB0952363AC40CBFE034080020E8C54E.42	Tue Nov  7 09:39:40 2006
--- /ade/tware_toplink10i/tltest/build.xml	Tue Nov  7 10:57:21 2006
***************
*** 387,393 ****
                  dir="${compile.essentials.destdir}"
                  includes="oracle/toplink/essentials/testing/models/cmp3/**"
                  excludes="oracle/toplink/essentials/testing/models/cmp3/validationfailed/**,
!                           oracle/toplink/essentials/testing/models/cmp3/xml/**"
              />
              <fileset
                  dir="${compile.essentials.resources}/ejb30-testing"
--- 387,394 ----
                  dir="${compile.essentials.destdir}"
                  includes="oracle/toplink/essentials/testing/models/cmp3/**"
                  excludes="oracle/toplink/essentials/testing/models/cmp3/validationfailed/**,
!                           oracle/toplink/essentials/testing/models/cmp3/xml/**,
!                           oracle/toplink/essentials/testing/models/cmp3/ddlgeneration/**"
              />
              <fileset
                  dir="${compile.essentials.resources}/ejb30-testing"
***************
*** 449,455 ****
          <jar jarfile="${_jarDestDir}/${ddl_generation_testmodel.jarfile}">
              <fileset
                  dir="${compile.essentials.destdir}"
!                 includes="oracle/toplink/essentials/testing/models/cmp3/xml/merge/inherited/**"
              />
              <fileset
                  dir="${compile.essentials.resources}/ddl-generation-testmodel"
--- 450,457 ----
          <jar jarfile="${_jarDestDir}/${ddl_generation_testmodel.jarfile}">
              <fileset
                  dir="${compile.essentials.destdir}"
!                 includes="oracle/toplink/essentials/testing/models/cmp3/xml/merge/inherited/**,
! 		          oracle/toplink/essentials/testing/models/cmp3/ddlgeneration/**"
              />
              <fileset
                  dir="${compile.essentials.resources}/ddl-generation-testmodel"
================================================================================
Merge Diffs: /ade/tware_toplink10i/tltest/test/data/tle.xml vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1072_table_generation_wonsoek_kim_061107/ade_storage/000024/AB0952363AC40CBFE034080020E8C54E.11
Report generated at Tue Nov  7 11:21:53 2006
--------------------------------------------------------------------------------
*** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1072_table_generation_wonsoek_kim_061107/ade_storage/000024/AB0952363AC40CBFE034080020E8C54E.11	Tue Nov  7 09:55:21 2006
--- /ade/tware_toplink10i/tltest/test/data/tle.xml	Tue Nov  7 10:57:21 2006
***************
*** 205,211 ****
  				<fileset dir="${toplink.testing.weaving.temp.dir.name}"
  					includes="oracle/toplink/essentials/testing/models/cmp3/**/*.class"
  					excludes="oracle/toplink/essentials/testing/models/cmp3/validationfailed/**/*.class,
! 						      oracle/toplink/essentials/testing/models/cmp3/xml/**/*.class"
  				/>
  			</copy>
  			<jar destfile="${toplink.testing.weaving.temp.dir.name}/toplink-essentials-annotation-model-tests.jar" basedir="${toplink.testing.weaving.temp.dir.name}_annotation"/>
--- 205,212 ----
  				<fileset dir="${toplink.testing.weaving.temp.dir.name}"
  					includes="oracle/toplink/essentials/testing/models/cmp3/**/*.class"
  					excludes="oracle/toplink/essentials/testing/models/cmp3/validationfailed/**/*.class,
! 						      oracle/toplink/essentials/testing/models/cmp3/xml/**/*.class,
! 						  oracle/toplink/essentials/testing/models/cmp3/ddlgeneration/**/*.class"
  				/>
  			</copy>
  			<jar destfile="${toplink.testing.weaving.temp.dir.name}/toplink-essentials-annotation-model-tests.jar" basedir="${toplink.testing.weaving.temp.dir.name}_annotation"/>