Class TableDefinition

    • Constructor Summary

      Constructors 
      Constructor Description
      TableDefinition()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addField​(java.lang.String fieldName, java.lang.Class type)
      PUBLIC: Add the field to the table, default sizes are used.
      void addField​(java.lang.String fieldName, java.lang.Class type, int fieldSize)
      PUBLIC: Add the field to the table.
      void addField​(java.lang.String fieldName, java.lang.Class type, int fieldSize, int fieldSubSize)
      PUBLIC: Add the field to the table.
      void addField​(java.lang.String fieldName, java.lang.String typeName)
      PUBLIC: Add the field to the type to a nested type.
      void addField​(FieldDefinition field)
      PUBLIC: Add the field to the table.
      void addFieldOnDatabase​(org.eclipse.persistence.internal.sessions.AbstractSession session, FieldDefinition field)
      INTERNAL: Execute the SQL alter table to add the field to the table.
      void addForeignKeyConstraint​(java.lang.String name, java.lang.String sourceField, java.lang.String targetField, java.lang.String targetTable)
      PUBLIC: Add a foreign key constraint to the table.
      void addForeignKeyConstraint​(ForeignKeyConstraint foreignKey)
      PUBLIC: Add a foreign key constraint to the table.
      void addIdentityField​(java.lang.String fieldName, java.lang.Class type)
      PUBLIC: Add the field to the table, default sizes are used.
      void addIdentityField​(java.lang.String fieldName, java.lang.Class type, int fieldSize)
      PUBLIC: Add the field to the table, default sizes are used.
      void addIndex​(IndexDefinition index)
      PUBLIC: Add an index to the table.
      void addPrimaryKeyField​(java.lang.String fieldName, java.lang.Class type)
      PUBLIC: Add the field to the table, default sizes are used.
      void addPrimaryKeyField​(java.lang.String fieldName, java.lang.Class type, int fieldSize)
      PUBLIC: Add the field to the table, default sizes are used.
      void addUniqueKeyConstraint​(java.lang.String name, java.lang.String sourceField)
      PUBLIC: Add a unique key constraint to the table.
      void addUniqueKeyConstraint​(java.lang.String name, java.lang.String[] sourceFields)
      PUBLIC: Add a unique key constraint to the table.
      void addUniqueKeyConstraint​(UniqueKeyConstraint uniqueKey)
      PUBLIC: Add a unique key constraint to the table.
      java.io.Writer buildAddFieldWriter​(org.eclipse.persistence.internal.sessions.AbstractSession session, FieldDefinition field, java.io.Writer writer)
      INTERNAL: Return the alter table statement to add a field to the table.
      java.io.Writer buildConstraintCreationWriter​(org.eclipse.persistence.internal.sessions.AbstractSession session, ForeignKeyConstraint foreignKey, java.io.Writer writer)
      INTERNAL: Return the alter table statement to add the constraints.
      java.io.Writer buildConstraintDeletionWriter​(org.eclipse.persistence.internal.sessions.AbstractSession session, ForeignKeyConstraint foreignKey, java.io.Writer writer)
      INTERNAL: Return the alter table statement to drop the constraints.
      java.io.Writer buildCreationWriter​(org.eclipse.persistence.internal.sessions.AbstractSession session, java.io.Writer writer)
      INTERNAL: Return the create table statement.
      java.io.Writer buildDeletionWriter​(org.eclipse.persistence.internal.sessions.AbstractSession session, java.io.Writer writer)
      INTERNAL: Return the drop table statement.
      IndexDefinition buildIndex​(org.eclipse.persistence.internal.sessions.AbstractSession session, java.lang.String key, java.util.List<java.lang.String> columnNames, boolean isUniqueSetOnField)
      INTERNAL: Return the index creation statement.
      java.io.Writer buildIndexDeletionWriter​(org.eclipse.persistence.internal.sessions.AbstractSession session, java.lang.String key, java.io.Writer writer, boolean isUniqueSetOnField)
      INTERNAL: Return the index drop statement.
      java.io.Writer buildUniqueConstraintCreationWriter​(org.eclipse.persistence.internal.sessions.AbstractSession session, UniqueKeyConstraint uniqueKey, java.io.Writer writer)
      INTERNAL: Return the alter table statement to add the constraints.
      java.io.Writer buildUniqueConstraintDeletionWriter​(org.eclipse.persistence.internal.sessions.AbstractSession session, UniqueKeyConstraint uniqueKey, java.io.Writer writer)
      INTERNAL: Return the alter table statement to drop the constraints.
      java.io.Writer buildVPDCreationFunctionWriter​(org.eclipse.persistence.internal.sessions.AbstractSession session, java.io.Writer writer)
      INTERNAL:
      java.io.Writer buildVPDCreationPolicyWriter​(org.eclipse.persistence.internal.sessions.AbstractSession session, java.io.Writer writer)
      INTERNAL:
      java.io.Writer buildVPDDeletionWriter​(org.eclipse.persistence.internal.sessions.AbstractSession session, java.io.Writer writer)
      INTERNAL:
      java.lang.Object clone()
      PUBLIC: Performs a deep copy of this table definition.
      void createConstraints​(org.eclipse.persistence.internal.sessions.AbstractSession session, java.io.Writer schemaWriter)
      INTERNAL: Execute the SQL alter table constraint creation string.
      void createConstraintsOnDatabase​(org.eclipse.persistence.internal.sessions.AbstractSession session)
      INTERNAL: Execute the SQL alter table constraint creation string.
      void createDatabaseSchema​(org.eclipse.persistence.internal.sessions.AbstractSession session, java.io.Writer writer, java.util.Set<java.lang.String> createdDatabaseSchemas)
      INTERNAL: Execute the DDL to create the database schema for this object.
      void createDatabaseSchemaOnDatabase​(org.eclipse.persistence.internal.sessions.AbstractSession session, java.util.Set<java.lang.String> createdDatabaseSchemas)
      INTERNAL: Execute the DDL to create the database schema for this object.
      void createIndexes​(org.eclipse.persistence.internal.sessions.AbstractSession session, java.io.Writer writer)
      INTERNAL:
      Write the SQL create index string to create index if passed a writer, else delegate to a method that executes the string on the database.
      java.lang.String deletionStringFor​(org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor accessor)
      INTERNAL: Return the delete SQL string.
      void dropConstraints​(org.eclipse.persistence.internal.sessions.AbstractSession session, java.io.Writer schemaWriter)
      INTERNAL: Execute the SQL alter table constraint creation string.
      void dropConstraintsOnDatabase​(org.eclipse.persistence.internal.sessions.AbstractSession session)
      INTERNAL: Execute the SQL alter table constraint creation string.
      void dropDatabaseSchema​(org.eclipse.persistence.internal.sessions.AbstractSession session, java.io.Writer writer)
      INTERNAL: Execute the DDL to drop the database schema for this object.
      void dropDatabaseSchemaOnDatabase​(org.eclipse.persistence.internal.sessions.AbstractSession session)
      INTERNAL: Execute the DDL to drop the database schema for this object.
      void dropIndexes​(org.eclipse.persistence.internal.sessions.AbstractSession session, java.io.Writer writer)
      INTERNAL:
      Write the SQL drop index string to drop indexes if passed a writer, else delegate to a method that executes the string on the database.
      java.lang.String getCreationPrefix()
      INTERNAL: Return the beginning of the sql create statement - the part before the name.
      java.lang.String getCreationSuffix()
      INTERNAL: Return the end of the sql create statement - the part after the field list.
      java.lang.String getDatabaseSchema()
      PUBLIC: Return the schema associated with this table.
      FieldDefinition getField​(java.lang.String fieldName)
      PUBLIC: Return the field the corresponds to the name.
      java.util.List<FieldDefinition> getFields()
      PUBLIC:
      java.util.Map<java.lang.String,​ForeignKeyConstraint> getForeignKeyMap()
      INTERNAL:
      java.util.Collection<ForeignKeyConstraint> getForeignKeys()
      PUBLIC: Returns the ForeignKeyConstraint list.
      java.util.List<IndexDefinition> getIndexes()
      PUBLIC:
      java.util.List<java.lang.String> getPrimaryKeyFieldNames()
      PUBLIC:
      org.eclipse.persistence.internal.helper.DatabaseTable getTable()  
      java.util.List<UniqueKeyConstraint> getUniqueKeys()
      PUBLIC:
      void postCreateObject​(org.eclipse.persistence.internal.sessions.AbstractSession session, java.io.Writer createSchemaWriter, boolean createSQLFiles)
      Execute any statements required after the creation of the object
      void preDropObject​(org.eclipse.persistence.internal.sessions.AbstractSession session, java.io.Writer dropSchemaWriter, boolean createSQLFiles)
      Execute any statements required before the deletion of the object
      void setCreateSQLFiles​(boolean genFlag)
      PUBLIC:
      void setCreateVPDCalls​(boolean createVPDCalls, java.lang.String tenantFieldName)
      PUBLIC:
      void setCreationPrefix​(java.lang.String creationPrefix)
      INTERNAL: Set the beginning of the sql create statement - the part before the name.
      void setCreationSuffix​(java.lang.String creationSuffix)
      INTERNAL: Set the end of the sql create statement - the part after the field list.
      void setFields​(java.util.List<FieldDefinition> fields)
      PUBLIC:
      void setForeignKeyMap​(java.util.Map<java.lang.String,​ForeignKeyConstraint> foreignKeyMap)
      INTERNAL:
      void setForeignKeys​(java.util.List<ForeignKeyConstraint> foreignKeys)
      PUBLIC: Set the ForeignKeyConstraint list.
      void setIndexes​(java.util.List<IndexDefinition> indexes)
      PUBLIC:
      void setTable​(org.eclipse.persistence.internal.helper.DatabaseTable table)  
      void setUniqueKeys​(java.util.List<UniqueKeyConstraint> uniqueKeys)
      PUBLIC:
      void setUserDefinedForeignKeyConstraints​(java.util.Map<java.lang.String,​ForeignKeyConstraint> foreignKeyConstraints)
      PUBLIC: Set the foreign key constraints for this table.
      boolean shouldCreateDatabaseSchema​(java.util.Set<java.lang.String> createdDatabaseSchemas)
      If this table has a schema (and catalog specified) make sure it is created.
      boolean shouldCreateVPDCalls​(org.eclipse.persistence.internal.sessions.AbstractSession session)
      INTERNAL: Subclasses who care should override this method.
      void writeLineSeperator​(org.eclipse.persistence.internal.sessions.AbstractSession session, java.io.Writer writer)  
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • TableDefinition

        public TableDefinition()
    • Method Detail

      • addField

        public void addField​(java.lang.String fieldName,
                             java.lang.Class type)
        PUBLIC: Add the field to the table, default sizes are used.
        Parameters:
        type - is the Java class type corresponding to the database type.
      • addField

        public void addField​(java.lang.String fieldName,
                             java.lang.Class type,
                             int fieldSize)
        PUBLIC: Add the field to the table.
        Parameters:
        type - is the Java class type corresponding to the database type.
      • addField

        public void addField​(java.lang.String fieldName,
                             java.lang.Class type,
                             int fieldSize,
                             int fieldSubSize)
        PUBLIC: Add the field to the table.
        Parameters:
        type - is the Java class type corresponding to the database type.
      • addField

        public void addField​(java.lang.String fieldName,
                             java.lang.String typeName)
        PUBLIC: Add the field to the type to a nested type.
        Parameters:
        typeName - is the name of the nested type.
      • addField

        public void addField​(FieldDefinition field)
        PUBLIC: Add the field to the table.
      • addFieldOnDatabase

        public void addFieldOnDatabase​(org.eclipse.persistence.internal.sessions.AbstractSession session,
                                       FieldDefinition field)
        INTERNAL: Execute the SQL alter table to add the field to the table.
      • buildAddFieldWriter

        public java.io.Writer buildAddFieldWriter​(org.eclipse.persistence.internal.sessions.AbstractSession session,
                                                  FieldDefinition field,
                                                  java.io.Writer writer)
                                           throws ValidationException
        INTERNAL: Return the alter table statement to add a field to the table.
        Throws:
        ValidationException
      • addForeignKeyConstraint

        public void addForeignKeyConstraint​(java.lang.String name,
                                            java.lang.String sourceField,
                                            java.lang.String targetField,
                                            java.lang.String targetTable)
        PUBLIC: Add a foreign key constraint to the table. If there is a same name foreign key constraint already, nothing will happen.
      • addUniqueKeyConstraint

        public void addUniqueKeyConstraint​(java.lang.String name,
                                           java.lang.String sourceField)
        PUBLIC: Add a unique key constraint to the table.
      • addUniqueKeyConstraint

        public void addUniqueKeyConstraint​(java.lang.String name,
                                           java.lang.String[] sourceFields)
        PUBLIC: Add a unique key constraint to the table.
      • addForeignKeyConstraint

        public void addForeignKeyConstraint​(ForeignKeyConstraint foreignKey)
        PUBLIC: Add a foreign key constraint to the table. If there is a same name foreign key constraint already, nothing will happen.
      • addUniqueKeyConstraint

        public void addUniqueKeyConstraint​(UniqueKeyConstraint uniqueKey)
        PUBLIC: Add a unique key constraint to the table.
      • addIndex

        public void addIndex​(IndexDefinition index)
        PUBLIC: Add an index to the table.
      • addIdentityField

        public void addIdentityField​(java.lang.String fieldName,
                                     java.lang.Class type)
        PUBLIC: Add the field to the table, default sizes are used. Identity fields are used on Sybase for native sequencing, The field must be of number type and cannot have a subsize.
        Parameters:
        type - is the Java class type corresponding to the database type.
      • addIdentityField

        public void addIdentityField​(java.lang.String fieldName,
                                     java.lang.Class type,
                                     int fieldSize)
        PUBLIC: Add the field to the table, default sizes are used. Identity fields are used on Sybase for native sequencing, The field must be of number type and cannot have a subsize.
        Parameters:
        type - is the Java class type corresponding to the database type.
      • addPrimaryKeyField

        public void addPrimaryKeyField​(java.lang.String fieldName,
                                       java.lang.Class type)
        PUBLIC: Add the field to the table, default sizes are used. This field is set as part of the primary key.
        Parameters:
        type - is the Java class type corresponding to the database type.
      • addPrimaryKeyField

        public void addPrimaryKeyField​(java.lang.String fieldName,
                                       java.lang.Class type,
                                       int fieldSize)
        PUBLIC: Add the field to the table, default sizes are used. This field is set as part of the primary key.
        Parameters:
        type - is the Java class type corresponding to the database type.
      • buildConstraintCreationWriter

        public java.io.Writer buildConstraintCreationWriter​(org.eclipse.persistence.internal.sessions.AbstractSession session,
                                                            ForeignKeyConstraint foreignKey,
                                                            java.io.Writer writer)
                                                     throws ValidationException
        INTERNAL: Return the alter table statement to add the constraints. This is done separately from the create because of dependencies.
        Throws:
        ValidationException
      • buildConstraintDeletionWriter

        public java.io.Writer buildConstraintDeletionWriter​(org.eclipse.persistence.internal.sessions.AbstractSession session,
                                                            ForeignKeyConstraint foreignKey,
                                                            java.io.Writer writer)
                                                     throws ValidationException
        INTERNAL: Return the alter table statement to drop the constraints. This is done separately to allow constraints to be dropped before the tables.
        Throws:
        ValidationException
      • buildUniqueConstraintCreationWriter

        public java.io.Writer buildUniqueConstraintCreationWriter​(org.eclipse.persistence.internal.sessions.AbstractSession session,
                                                                  UniqueKeyConstraint uniqueKey,
                                                                  java.io.Writer writer)
                                                           throws ValidationException
        INTERNAL: Return the alter table statement to add the constraints. This is done separately from the create because of dependencies.
        Throws:
        ValidationException
      • buildUniqueConstraintDeletionWriter

        public java.io.Writer buildUniqueConstraintDeletionWriter​(org.eclipse.persistence.internal.sessions.AbstractSession session,
                                                                  UniqueKeyConstraint uniqueKey,
                                                                  java.io.Writer writer)
                                                           throws ValidationException
        INTERNAL: Return the alter table statement to drop the constraints. This is done separately to allow constraints to be dropped before the tables.
        Throws:
        ValidationException
      • buildIndex

        public IndexDefinition buildIndex​(org.eclipse.persistence.internal.sessions.AbstractSession session,
                                          java.lang.String key,
                                          java.util.List<java.lang.String> columnNames,
                                          boolean isUniqueSetOnField)
        INTERNAL: Return the index creation statement.
      • buildIndexDeletionWriter

        public java.io.Writer buildIndexDeletionWriter​(org.eclipse.persistence.internal.sessions.AbstractSession session,
                                                       java.lang.String key,
                                                       java.io.Writer writer,
                                                       boolean isUniqueSetOnField)
        INTERNAL: Return the index drop statement.
      • getCreationPrefix

        public java.lang.String getCreationPrefix()
        INTERNAL: Return the beginning of the sql create statement - the part before the name. Unless temp table is created should be "CREATE TABLE "
      • setCreationPrefix

        public void setCreationPrefix​(java.lang.String creationPrefix)
        INTERNAL: Set the beginning of the sql create statement - the part before the name. Use to create temp. table.
      • getCreationSuffix

        public java.lang.String getCreationSuffix()
        INTERNAL: Return the end of the sql create statement - the part after the field list. Unless temp table is created should be empty.
      • setCreationSuffix

        public void setCreationSuffix​(java.lang.String creationSuffix)
        INTERNAL: Set the end of the sql create statement - the part after the field list.
      • buildVPDCreationPolicyWriter

        public java.io.Writer buildVPDCreationPolicyWriter​(org.eclipse.persistence.internal.sessions.AbstractSession session,
                                                           java.io.Writer writer)
        INTERNAL:
        Overrides:
        buildVPDCreationPolicyWriter in class DatabaseObjectDefinition
      • buildVPDCreationFunctionWriter

        public java.io.Writer buildVPDCreationFunctionWriter​(org.eclipse.persistence.internal.sessions.AbstractSession session,
                                                             java.io.Writer writer)
        INTERNAL:
        Overrides:
        buildVPDCreationFunctionWriter in class DatabaseObjectDefinition
      • buildVPDDeletionWriter

        public java.io.Writer buildVPDDeletionWriter​(org.eclipse.persistence.internal.sessions.AbstractSession session,
                                                     java.io.Writer writer)
        INTERNAL:
        Overrides:
        buildVPDDeletionWriter in class DatabaseObjectDefinition
      • clone

        public java.lang.Object clone()
        PUBLIC: Performs a deep copy of this table definition.
        Overrides:
        clone in class DatabaseObjectDefinition
      • createConstraints

        public void createConstraints​(org.eclipse.persistence.internal.sessions.AbstractSession session,
                                      java.io.Writer schemaWriter)
                               throws EclipseLinkException
        INTERNAL: Execute the SQL alter table constraint creation string.
        Throws:
        EclipseLinkException
      • createConstraintsOnDatabase

        public void createConstraintsOnDatabase​(org.eclipse.persistence.internal.sessions.AbstractSession session)
                                         throws EclipseLinkException
        INTERNAL: Execute the SQL alter table constraint creation string.
        Throws:
        EclipseLinkException
      • createIndexes

        public void createIndexes​(org.eclipse.persistence.internal.sessions.AbstractSession session,
                                  java.io.Writer writer)
        INTERNAL:
        Write the SQL create index string to create index if passed a writer, else delegate to a method that executes the string on the database.
        Throws:
        ValidationException - wraps any IOException from the writer
      • writeLineSeperator

        public void writeLineSeperator​(org.eclipse.persistence.internal.sessions.AbstractSession session,
                                       java.io.Writer writer)
      • deletionStringFor

        public java.lang.String deletionStringFor​(org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor accessor)
        INTERNAL: Return the delete SQL string.
      • dropConstraints

        public void dropConstraints​(org.eclipse.persistence.internal.sessions.AbstractSession session,
                                    java.io.Writer schemaWriter)
                             throws EclipseLinkException
        INTERNAL: Execute the SQL alter table constraint creation string.
        Throws:
        EclipseLinkException
      • dropConstraintsOnDatabase

        public void dropConstraintsOnDatabase​(org.eclipse.persistence.internal.sessions.AbstractSession session)
                                       throws EclipseLinkException
        INTERNAL: Execute the SQL alter table constraint creation string. Exceptions are caught and masked so that all the foreign keys are dropped (even if they don't exist).
        Throws:
        EclipseLinkException
      • dropIndexes

        public void dropIndexes​(org.eclipse.persistence.internal.sessions.AbstractSession session,
                                java.io.Writer writer)
        INTERNAL:
        Write the SQL drop index string to drop indexes if passed a writer, else delegate to a method that executes the string on the database.
        Throws:
        ValidationException - wraps any IOException from the writer
      • getForeignKeyMap

        public java.util.Map<java.lang.String,​ForeignKeyConstraint> getForeignKeyMap()
        INTERNAL:
      • setForeignKeyMap

        public void setForeignKeyMap​(java.util.Map<java.lang.String,​ForeignKeyConstraint> foreignKeyMap)
        INTERNAL:
      • getField

        public FieldDefinition getField​(java.lang.String fieldName)
        PUBLIC: Return the field the corresponds to the name.
      • getForeignKeys

        public java.util.Collection<ForeignKeyConstraint> getForeignKeys()
        PUBLIC: Returns the ForeignKeyConstraint list.
      • setIndexes

        public void setIndexes​(java.util.List<IndexDefinition> indexes)
        PUBLIC:
      • setCreateVPDCalls

        public void setCreateVPDCalls​(boolean createVPDCalls,
                                      java.lang.String tenantFieldName)
        PUBLIC:
      • getPrimaryKeyFieldNames

        public java.util.List<java.lang.String> getPrimaryKeyFieldNames()
        PUBLIC:
      • postCreateObject

        public void postCreateObject​(org.eclipse.persistence.internal.sessions.AbstractSession session,
                                     java.io.Writer createSchemaWriter,
                                     boolean createSQLFiles)
        Execute any statements required after the creation of the object
        Overrides:
        postCreateObject in class DatabaseObjectDefinition
        Parameters:
        session -
        createSchemaWriter -
      • preDropObject

        public void preDropObject​(org.eclipse.persistence.internal.sessions.AbstractSession session,
                                  java.io.Writer dropSchemaWriter,
                                  boolean createSQLFiles)
        Execute any statements required before the deletion of the object
        Overrides:
        preDropObject in class DatabaseObjectDefinition
        Parameters:
        session -
        dropSchemaWriter -
      • setFields

        public void setFields​(java.util.List<FieldDefinition> fields)
        PUBLIC:
      • setForeignKeys

        public void setForeignKeys​(java.util.List<ForeignKeyConstraint> foreignKeys)
        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.
      • setUniqueKeys

        public void setUniqueKeys​(java.util.List<UniqueKeyConstraint> uniqueKeys)
        PUBLIC:
      • setUserDefinedForeignKeyConstraints

        public void setUserDefinedForeignKeyConstraints​(java.util.Map<java.lang.String,​ForeignKeyConstraint> foreignKeyConstraints)
        PUBLIC: Set the foreign key constraints for this table.
      • shouldCreateDatabaseSchema

        public boolean shouldCreateDatabaseSchema​(java.util.Set<java.lang.String> createdDatabaseSchemas)
        If this table has a schema (and catalog specified) make sure it is created.
        Overrides:
        shouldCreateDatabaseSchema in class DatabaseObjectDefinition
      • shouldCreateVPDCalls

        public boolean shouldCreateVPDCalls​(org.eclipse.persistence.internal.sessions.AbstractSession session)
        INTERNAL: Subclasses who care should override this method.
        Overrides:
        shouldCreateVPDCalls in class DatabaseObjectDefinition
      • setCreateSQLFiles

        public void setCreateSQLFiles​(boolean genFlag)
        PUBLIC:
      • getTable

        public org.eclipse.persistence.internal.helper.DatabaseTable getTable()
      • setTable

        public void setTable​(org.eclipse.persistence.internal.helper.DatabaseTable table)