Class TableDefinition
- java.lang.Object
-
- org.eclipse.persistence.tools.schemaframework.DatabaseObjectDefinition
-
- org.eclipse.persistence.tools.schemaframework.TableDefinition
-
- All Implemented Interfaces:
Serializable,Cloneable
- Direct Known Subclasses:
TypeTableDefinition
public class TableDefinition extends DatabaseObjectDefinition
Purpose: Allow a generic way of creating tables on the different platforms.
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class org.eclipse.persistence.tools.schemaframework.DatabaseObjectDefinition
name, qualifier
-
-
Constructor Summary
Constructors Constructor Description TableDefinition()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddField(String fieldName, Class type)PUBLIC: Add the field to the table, default sizes are used.voidaddField(String fieldName, Class type, int fieldSize)PUBLIC: Add the field to the table.voidaddField(String fieldName, Class type, int fieldSize, int fieldSubSize)PUBLIC: Add the field to the table.voidaddField(String fieldName, String typeName)PUBLIC: Add the field to the type to a nested type.voidaddField(FieldDefinition field)PUBLIC: Add the field to the table.voidaddFieldOnDatabase(org.eclipse.persistence.internal.sessions.AbstractSession session, FieldDefinition field)INTERNAL: Execute the SQL alter table to add the field to the table.voidaddForeignKeyConstraint(String name, String sourceField, String targetField, String targetTable)PUBLIC: Add a foreign key constraint to the table.voidaddForeignKeyConstraint(ForeignKeyConstraint foreignKey)PUBLIC: Add a foreign key constraint to the table.voidaddIdentityField(String fieldName, Class type)PUBLIC: Add the field to the table, default sizes are used.voidaddIdentityField(String fieldName, Class type, int fieldSize)PUBLIC: Add the field to the table, default sizes are used.voidaddIndex(IndexDefinition index)PUBLIC: Add an index to the table.voidaddPrimaryKeyField(String fieldName, Class type)PUBLIC: Add the field to the table, default sizes are used.voidaddPrimaryKeyField(String fieldName, Class type, int fieldSize)PUBLIC: Add the field to the table, default sizes are used.voidaddUniqueKeyConstraint(String name, String sourceField)PUBLIC: Add a unique key constraint to the table.voidaddUniqueKeyConstraint(String name, String[] sourceFields)PUBLIC: Add a unique key constraint to the table.voidaddUniqueKeyConstraint(UniqueKeyConstraint uniqueKey)PUBLIC: Add a unique key constraint to the table.WriterbuildAddFieldWriter(org.eclipse.persistence.internal.sessions.AbstractSession session, FieldDefinition field, Writer writer)INTERNAL: Return the alter table statement to add a field to the table.WriterbuildConstraintCreationWriter(org.eclipse.persistence.internal.sessions.AbstractSession session, ForeignKeyConstraint foreignKey, Writer writer)INTERNAL: Return the alter table statement to add the constraints.WriterbuildConstraintDeletionWriter(org.eclipse.persistence.internal.sessions.AbstractSession session, ForeignKeyConstraint foreignKey, Writer writer)INTERNAL: Return the alter table statement to drop the constraints.WriterbuildCreationWriter(org.eclipse.persistence.internal.sessions.AbstractSession session, Writer writer)INTERNAL: Return the create table statement.WriterbuildDeletionWriter(org.eclipse.persistence.internal.sessions.AbstractSession session, Writer writer)INTERNAL: Return the drop table statement.IndexDefinitionbuildIndex(org.eclipse.persistence.internal.sessions.AbstractSession session, String key, List<String> columnNames, boolean isUniqueSetOnField)INTERNAL: Return the index creation statement.WriterbuildIndexDeletionWriter(org.eclipse.persistence.internal.sessions.AbstractSession session, String key, Writer writer, boolean isUniqueSetOnField)INTERNAL: Return the index drop statement.WriterbuildUniqueConstraintCreationWriter(org.eclipse.persistence.internal.sessions.AbstractSession session, UniqueKeyConstraint uniqueKey, Writer writer)INTERNAL: Return the alter table statement to add the constraints.WriterbuildUniqueConstraintDeletionWriter(org.eclipse.persistence.internal.sessions.AbstractSession session, UniqueKeyConstraint uniqueKey, Writer writer)INTERNAL: Return the alter table statement to drop the constraints.WriterbuildVPDCreationFunctionWriter(org.eclipse.persistence.internal.sessions.AbstractSession session, Writer writer)INTERNAL:WriterbuildVPDCreationPolicyWriter(org.eclipse.persistence.internal.sessions.AbstractSession session, Writer writer)INTERNAL:WriterbuildVPDDeletionWriter(org.eclipse.persistence.internal.sessions.AbstractSession session, Writer writer)INTERNAL:Objectclone()PUBLIC: Performs a deep copy of this table definition.voidcreateConstraints(org.eclipse.persistence.internal.sessions.AbstractSession session, Writer schemaWriter)INTERNAL: Execute the SQL alter table constraint creation string.voidcreateConstraintsOnDatabase(org.eclipse.persistence.internal.sessions.AbstractSession session)INTERNAL: Execute the SQL alter table constraint creation string.voidcreateDatabaseSchema(org.eclipse.persistence.internal.sessions.AbstractSession session, Writer writer, Set<String> createdDatabaseSchemas)INTERNAL: Execute the DDL to create the database schema for this object.voidcreateDatabaseSchemaOnDatabase(org.eclipse.persistence.internal.sessions.AbstractSession session, Set<String> createdDatabaseSchemas)INTERNAL: Execute the DDL to create the database schema for this object.voidcreateIndexes(org.eclipse.persistence.internal.sessions.AbstractSession session, 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.StringdeletionStringFor(org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor accessor)INTERNAL: Return the delete SQL string.voiddropConstraints(org.eclipse.persistence.internal.sessions.AbstractSession session, Writer schemaWriter)INTERNAL: Execute the SQL alter table constraint creation string.voiddropConstraintsOnDatabase(org.eclipse.persistence.internal.sessions.AbstractSession session)INTERNAL: Execute the SQL alter table constraint creation string.voiddropDatabaseSchema(org.eclipse.persistence.internal.sessions.AbstractSession session, Writer writer)INTERNAL: Execute the DDL to drop the database schema for this object.voiddropDatabaseSchemaOnDatabase(org.eclipse.persistence.internal.sessions.AbstractSession session)INTERNAL: Execute the DDL to drop the database schema for this object.voiddropIndexes(org.eclipse.persistence.internal.sessions.AbstractSession session, 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.StringgetCreationPrefix()INTERNAL: Return the beginning of the sql create statement - the part before the name.StringgetCreationSuffix()INTERNAL: Return the end of the sql create statement - the part after the field list.StringgetDatabaseSchema()PUBLIC: Return the schema associated with this table.FieldDefinitiongetField(String fieldName)PUBLIC: Return the field the corresponds to the name.List<FieldDefinition>getFields()PUBLIC:Map<String,ForeignKeyConstraint>getForeignKeyMap()INTERNAL:Collection<ForeignKeyConstraint>getForeignKeys()PUBLIC: Returns the ForeignKeyConstraint list.List<IndexDefinition>getIndexes()PUBLIC:List<String>getPrimaryKeyFieldNames()PUBLIC:org.eclipse.persistence.internal.helper.DatabaseTablegetTable()List<UniqueKeyConstraint>getUniqueKeys()PUBLIC:voidpostCreateObject(org.eclipse.persistence.internal.sessions.AbstractSession session, Writer createSchemaWriter, boolean createSQLFiles)Execute any statements required after the creation of the objectvoidpreDropObject(org.eclipse.persistence.internal.sessions.AbstractSession session, Writer dropSchemaWriter, boolean createSQLFiles)Execute any statements required before the deletion of the objectvoidsetCreateSQLFiles(boolean genFlag)PUBLIC:voidsetCreateVPDCalls(boolean createVPDCalls, String tenantFieldName)PUBLIC:voidsetCreationPrefix(String creationPrefix)INTERNAL: Set the beginning of the sql create statement - the part before the name.voidsetCreationSuffix(String creationSuffix)INTERNAL: Set the end of the sql create statement - the part after the field list.voidsetFields(List<FieldDefinition> fields)PUBLIC:voidsetForeignKeyMap(Map<String,ForeignKeyConstraint> foreignKeyMap)INTERNAL:voidsetForeignKeys(List<ForeignKeyConstraint> foreignKeys)PUBLIC: Set the ForeignKeyConstraint list.voidsetIndexes(List<IndexDefinition> indexes)PUBLIC:voidsetTable(org.eclipse.persistence.internal.helper.DatabaseTable table)voidsetUniqueKeys(List<UniqueKeyConstraint> uniqueKeys)PUBLIC:voidsetUserDefinedForeignKeyConstraints(Map<String,ForeignKeyConstraint> foreignKeyConstraints)PUBLIC: Set the foreign key constraints for this table.booleanshouldCreateDatabaseSchema(Set<String> createdDatabaseSchemas)If this table has a schema (and catalog specified) make sure it is created.booleanshouldCreateVPDCalls(org.eclipse.persistence.internal.sessions.AbstractSession session)INTERNAL: Subclasses who care should override this method.voidwriteLineSeperator(org.eclipse.persistence.internal.sessions.AbstractSession session, Writer writer)-
Methods inherited from class org.eclipse.persistence.tools.schemaframework.DatabaseObjectDefinition
createObject, createOnDatabase, dropFromDatabase, dropObject, getFullName, getName, getQualifier, setName, setQualifier, toString
-
-
-
-
Method Detail
-
addField
public void addField(String fieldName, 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(String fieldName, 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(String fieldName, 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(String fieldName, 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 Writer buildAddFieldWriter(org.eclipse.persistence.internal.sessions.AbstractSession session, FieldDefinition field, Writer writer) throws ValidationException
INTERNAL: Return the alter table statement to add a field to the table.- Throws:
ValidationException
-
addForeignKeyConstraint
public void addForeignKeyConstraint(String name, String sourceField, String targetField, 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(String name, String sourceField)
PUBLIC: Add a unique key constraint to the table.
-
addUniqueKeyConstraint
public void addUniqueKeyConstraint(String name, 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(String fieldName, 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(String fieldName, 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(String fieldName, 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(String fieldName, 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 Writer buildConstraintCreationWriter(org.eclipse.persistence.internal.sessions.AbstractSession session, ForeignKeyConstraint foreignKey, 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 Writer buildConstraintDeletionWriter(org.eclipse.persistence.internal.sessions.AbstractSession session, ForeignKeyConstraint foreignKey, 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 Writer buildUniqueConstraintCreationWriter(org.eclipse.persistence.internal.sessions.AbstractSession session, UniqueKeyConstraint uniqueKey, 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 Writer buildUniqueConstraintDeletionWriter(org.eclipse.persistence.internal.sessions.AbstractSession session, UniqueKeyConstraint uniqueKey, 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, String key, List<String> columnNames, boolean isUniqueSetOnField)
INTERNAL: Return the index creation statement.
-
buildIndexDeletionWriter
public Writer buildIndexDeletionWriter(org.eclipse.persistence.internal.sessions.AbstractSession session, String key, Writer writer, boolean isUniqueSetOnField)
INTERNAL: Return the index drop statement.
-
getCreationPrefix
public 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(String creationPrefix)
INTERNAL: Set the beginning of the sql create statement - the part before the name. Use to create temp. table.
-
getCreationSuffix
public 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.
-
getDatabaseSchema
public String getDatabaseSchema()
PUBLIC: Return the schema associated with this table.- Overrides:
getDatabaseSchemain classDatabaseObjectDefinition- See Also:
TableDefinition
-
setCreationSuffix
public void setCreationSuffix(String creationSuffix)
INTERNAL: Set the end of the sql create statement - the part after the field list.
-
buildCreationWriter
public Writer buildCreationWriter(org.eclipse.persistence.internal.sessions.AbstractSession session, Writer writer) throws ValidationException
INTERNAL: Return the create table statement.- Specified by:
buildCreationWriterin classDatabaseObjectDefinition- Throws:
ValidationException
-
buildDeletionWriter
public Writer buildDeletionWriter(org.eclipse.persistence.internal.sessions.AbstractSession session, Writer writer) throws ValidationException
INTERNAL: Return the drop table statement.- Specified by:
buildDeletionWriterin classDatabaseObjectDefinition- Throws:
ValidationException
-
buildVPDCreationPolicyWriter
public Writer buildVPDCreationPolicyWriter(org.eclipse.persistence.internal.sessions.AbstractSession session, Writer writer)
INTERNAL:- Overrides:
buildVPDCreationPolicyWriterin classDatabaseObjectDefinition
-
buildVPDCreationFunctionWriter
public Writer buildVPDCreationFunctionWriter(org.eclipse.persistence.internal.sessions.AbstractSession session, Writer writer)
INTERNAL:- Overrides:
buildVPDCreationFunctionWriterin classDatabaseObjectDefinition
-
buildVPDDeletionWriter
public Writer buildVPDDeletionWriter(org.eclipse.persistence.internal.sessions.AbstractSession session, Writer writer)
INTERNAL:- Overrides:
buildVPDDeletionWriterin classDatabaseObjectDefinition
-
clone
public Object clone()
PUBLIC: Performs a deep copy of this table definition.- Overrides:
clonein classDatabaseObjectDefinition
-
createConstraints
public void createConstraints(org.eclipse.persistence.internal.sessions.AbstractSession session, Writer schemaWriter) throws EclipseLinkExceptionINTERNAL: Execute the SQL alter table constraint creation string.- Throws:
EclipseLinkException
-
createConstraintsOnDatabase
public void createConstraintsOnDatabase(org.eclipse.persistence.internal.sessions.AbstractSession session) throws EclipseLinkExceptionINTERNAL: Execute the SQL alter table constraint creation string.- Throws:
EclipseLinkException
-
createDatabaseSchema
public void createDatabaseSchema(org.eclipse.persistence.internal.sessions.AbstractSession session, Writer writer, Set<String> createdDatabaseSchemas) throws EclipseLinkExceptionINTERNAL: Execute the DDL to create the database schema for this object.- Overrides:
createDatabaseSchemain classDatabaseObjectDefinition- Throws:
EclipseLinkException- See Also:
TableDefinition
-
createDatabaseSchemaOnDatabase
public void createDatabaseSchemaOnDatabase(org.eclipse.persistence.internal.sessions.AbstractSession session, Set<String> createdDatabaseSchemas) throws EclipseLinkExceptionINTERNAL: Execute the DDL to create the database schema for this object.- Overrides:
createDatabaseSchemaOnDatabasein classDatabaseObjectDefinition- Throws:
EclipseLinkException- See Also:
TableDefinition
-
createIndexes
public void createIndexes(org.eclipse.persistence.internal.sessions.AbstractSession session, 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, Writer writer)
-
deletionStringFor
public String deletionStringFor(org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor accessor)
INTERNAL: Return the delete SQL string.
-
dropDatabaseSchema
public void dropDatabaseSchema(org.eclipse.persistence.internal.sessions.AbstractSession session, Writer writer) throws EclipseLinkExceptionINTERNAL: Execute the DDL to drop the database schema for this object.- Overrides:
dropDatabaseSchemain classDatabaseObjectDefinition- Throws:
EclipseLinkException- See Also:
TableDefinition
-
dropDatabaseSchemaOnDatabase
public void dropDatabaseSchemaOnDatabase(org.eclipse.persistence.internal.sessions.AbstractSession session) throws EclipseLinkExceptionINTERNAL: Execute the DDL to drop the database schema for this object.- Overrides:
dropDatabaseSchemaOnDatabasein classDatabaseObjectDefinition- Throws:
EclipseLinkException- See Also:
TableDefinition
-
dropConstraints
public void dropConstraints(org.eclipse.persistence.internal.sessions.AbstractSession session, Writer schemaWriter) throws EclipseLinkExceptionINTERNAL: Execute the SQL alter table constraint creation string.- Throws:
EclipseLinkException
-
dropConstraintsOnDatabase
public void dropConstraintsOnDatabase(org.eclipse.persistence.internal.sessions.AbstractSession session) throws EclipseLinkExceptionINTERNAL: 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, 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 Map<String,ForeignKeyConstraint> getForeignKeyMap()
INTERNAL:
-
setForeignKeyMap
public void setForeignKeyMap(Map<String,ForeignKeyConstraint> foreignKeyMap)
INTERNAL:
-
getField
public FieldDefinition getField(String fieldName)
PUBLIC: Return the field the corresponds to the name.
-
getFields
public List<FieldDefinition> getFields()
PUBLIC:
-
getForeignKeys
public Collection<ForeignKeyConstraint> getForeignKeys()
PUBLIC: Returns the ForeignKeyConstraint list.
-
getUniqueKeys
public List<UniqueKeyConstraint> getUniqueKeys()
PUBLIC:
-
setIndexes
public void setIndexes(List<IndexDefinition> indexes)
PUBLIC:
-
setCreateVPDCalls
public void setCreateVPDCalls(boolean createVPDCalls, String tenantFieldName)PUBLIC:
-
getIndexes
public List<IndexDefinition> getIndexes()
PUBLIC:
-
postCreateObject
public void postCreateObject(org.eclipse.persistence.internal.sessions.AbstractSession session, Writer createSchemaWriter, boolean createSQLFiles)Execute any statements required after the creation of the object- Overrides:
postCreateObjectin classDatabaseObjectDefinition- Parameters:
session-createSchemaWriter-
-
preDropObject
public void preDropObject(org.eclipse.persistence.internal.sessions.AbstractSession session, Writer dropSchemaWriter, boolean createSQLFiles)Execute any statements required before the deletion of the object- Overrides:
preDropObjectin classDatabaseObjectDefinition- Parameters:
session-dropSchemaWriter-
-
setFields
public void setFields(List<FieldDefinition> fields)
PUBLIC:
-
setForeignKeys
public void setForeignKeys(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(List<UniqueKeyConstraint> uniqueKeys)
PUBLIC:
-
setUserDefinedForeignKeyConstraints
public void setUserDefinedForeignKeyConstraints(Map<String,ForeignKeyConstraint> foreignKeyConstraints)
PUBLIC: Set the foreign key constraints for this table.
-
shouldCreateDatabaseSchema
public boolean shouldCreateDatabaseSchema(Set<String> createdDatabaseSchemas)
If this table has a schema (and catalog specified) make sure it is created.- Overrides:
shouldCreateDatabaseSchemain classDatabaseObjectDefinition
-
shouldCreateVPDCalls
public boolean shouldCreateVPDCalls(org.eclipse.persistence.internal.sessions.AbstractSession session)
INTERNAL: Subclasses who care should override this method.- Overrides:
shouldCreateVPDCallsin classDatabaseObjectDefinition
-
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)
-
-