public class TableDefinition extends DatabaseObjectDefinition
Purpose: Allow a generic way of creating tables on the different platforms.
Modifier and Type | Field and Description |
---|---|
protected java.lang.String |
creationPrefix |
protected java.lang.String |
creationSuffix |
protected java.util.Vector |
fields |
protected java.util.HashMap<java.lang.String,ForeignKeyConstraint> |
foreignKeyMap |
protected java.util.Vector<UniqueKeyConstraint> |
uniqueKeys |
name, qualifier
Constructor and Description |
---|
TableDefinition() |
Modifier and Type | Method and Description |
---|---|
void |
addField(FieldDefinition field)
PUBLIC:
Add the field to the table.
|
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 |
addForeignKeyConstraint(ForeignKeyConstraint foreignKey)
PUBLIC:
Add a foreign key constraint 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 |
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 |
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 |
buildConstraintCreationWriter(AbstractSession session,
ForeignKeyConstraint foreignKey,
java.io.Writer writer)
INTERNAL:
Return the alter table statement to add the constraints.
|
java.io.Writer |
buildConstraintDeletionWriter(AbstractSession session,
ForeignKeyConstraint foreignKey,
java.io.Writer writer)
INTERNAL:
Return the alter table statement to drop the constraints.
|
java.io.Writer |
buildCreationWriter(AbstractSession session,
java.io.Writer writer)
INTERNAL:
Return the create table statement.
|
java.io.Writer |
buildDeletionWriter(AbstractSession session,
java.io.Writer writer)
INTERNAL:
Return the drop table statement.
|
protected void |
buildFieldTypes(AbstractSession session)
INTERNAL:
Build the foriegn key constraints.
|
protected ForeignKeyConstraint |
buildForeignKeyConstraint(FieldDefinition field,
DatabasePlatform platform)
Build a foriegn key constraint using FieldDefinition.getForeignKeyFieldName().
|
protected ForeignKeyConstraint |
buildForeignKeyConstraint(java.util.Vector fkFieldNames,
java.util.Vector pkFieldNames,
TableDefinition targetTable,
DatabasePlatform platform)
Build a foriegn key constraint.
|
protected java.lang.String |
buildForeignKeyConstraintName(java.lang.String tableName,
java.lang.String fieldName,
int maximumNameLength)
Return foreign key constraint name built from the table and field name with the specified maximum length.
|
java.io.Writer |
buildUniqueConstraintCreationWriter(AbstractSession session,
UniqueKeyConstraint uniqueKey,
java.io.Writer writer)
INTERNAL:
Return the alter table statement to add the constraints.
|
java.io.Writer |
buildUniqueConstraintDeletionWriter(AbstractSession session,
UniqueKeyConstraint uniqueKey,
java.io.Writer writer)
INTERNAL:
Return the alter table statement to drop the constraints.
|
protected UniqueKeyConstraint |
buildUniqueKeyConstraint(java.lang.String[] fieldNames,
int serialNumber,
DatabasePlatform platform) |
protected java.lang.String |
buildUniqueKeyConstraintName(java.lang.String tableName,
int serialNumber,
int maximumNameLength)
Return unique key constraint name built from the table and field name with the specified maximum length.
|
java.lang.Object |
clone()
PUBLIC:
Performs a deep copy of this table definition.
|
void |
createConstraints(AbstractSession session,
java.io.Writer schemaWriter)
INTERNAL:
Execute the SQL alter table constraint creation string.
|
void |
createConstraintsOnDatabase(AbstractSession session)
INTERNAL:
Execute the SQL alter table constraint creation string.
|
java.lang.String |
deletionStringFor(DatabaseAccessor accessor)
INTERNAL:
Return the delete SQL string.
|
void |
dropConstraints(AbstractSession session,
java.io.Writer schemaWriter)
INTERNAL:
Execute the SQL alter table constraint creation string.
|
void |
dropConstraintsOnDatabase(AbstractSession session)
INTERNAL:
Execute the SQL alter table constraint creation string.
|
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.util.Vector |
getFields()
PUBLIC:
|
java.util.Vector<ForeignKeyConstraint> |
getForeignKeys()
PUBLIC:
Returns the ForeignKeyConstraint list.
|
java.util.Vector |
getPrimaryKeyFieldNames()
PUBLIC:
|
java.util.Vector<UniqueKeyConstraint> |
getUniqueKeys()
PUBLIC:
|
void |
setCreateSQLFiles(boolean genFlag)
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.Vector fields)
PUBLIC:
|
void |
setForeignKeys(java.util.Vector<ForeignKeyConstraint> foreignKeys)
PUBLIC:
Set the ForeignKeyConstraint list.
|
void |
setUniqueKeys(java.util.Vector<UniqueKeyConstraint> uniqueKeys)
PUBLIC:
|
createObject, createOnDatabase, dropFromDatabase, dropObject, getFullName, getName, getQualifier, setName, setQualifier, toString
protected java.util.Vector fields
protected java.util.HashMap<java.lang.String,ForeignKeyConstraint> foreignKeyMap
protected java.util.Vector<UniqueKeyConstraint> uniqueKeys
protected java.lang.String creationPrefix
protected java.lang.String creationSuffix
public void addField(java.lang.String fieldName, java.lang.Class type)
type
- is the Java class type coresponding to the database type.public void addField(java.lang.String fieldName, java.lang.Class type, int fieldSize)
type
- is the Java class type coresponding to the database type.public void addField(java.lang.String fieldName, java.lang.Class type, int fieldSize, int fieldSubSize)
type
- is the Java class type coresponding to the database type.public void addField(java.lang.String fieldName, java.lang.String typeName)
typeName
- is the name of the nested type.public void addField(FieldDefinition field)
public void addForeignKeyConstraint(java.lang.String name, java.lang.String sourceField, java.lang.String targetField, java.lang.String targetTable)
public void addUniqueKeyConstraint(java.lang.String name, java.lang.String sourceField)
public void addUniqueKeyConstraint(java.lang.String name, java.lang.String[] sourceFields)
public void addForeignKeyConstraint(ForeignKeyConstraint foreignKey)
public void addUniqueKeyConstraint(UniqueKeyConstraint uniqueKey)
public void addIdentityField(java.lang.String fieldName, java.lang.Class type)
type
- is the Java class type coresponding to the database type.public void addIdentityField(java.lang.String fieldName, java.lang.Class type, int fieldSize)
type
- is the Java class type coresponding to the database type.public void addPrimaryKeyField(java.lang.String fieldName, java.lang.Class type)
type
- is the Java class type coresponding to the database type.public void addPrimaryKeyField(java.lang.String fieldName, java.lang.Class type, int fieldSize)
type
- is the Java class type coresponding to the database type.public java.io.Writer buildConstraintCreationWriter(AbstractSession session, ForeignKeyConstraint foreignKey, java.io.Writer writer) throws ValidationException
ValidationException
public java.io.Writer buildConstraintDeletionWriter(AbstractSession session, ForeignKeyConstraint foreignKey, java.io.Writer writer) throws ValidationException
ValidationException
public java.io.Writer buildUniqueConstraintCreationWriter(AbstractSession session, UniqueKeyConstraint uniqueKey, java.io.Writer writer) throws ValidationException
ValidationException
public java.io.Writer buildUniqueConstraintDeletionWriter(AbstractSession session, UniqueKeyConstraint uniqueKey, java.io.Writer writer) throws ValidationException
ValidationException
public java.lang.String getCreationPrefix()
public void setCreationPrefix(java.lang.String creationPrefix)
public java.lang.String getCreationSuffix()
public void setCreationSuffix(java.lang.String creationSuffix)
public java.io.Writer buildCreationWriter(AbstractSession session, java.io.Writer writer) throws ValidationException
buildCreationWriter
in class DatabaseObjectDefinition
ValidationException
public java.io.Writer buildDeletionWriter(AbstractSession session, java.io.Writer writer) throws ValidationException
buildDeletionWriter
in class DatabaseObjectDefinition
ValidationException
protected void buildFieldTypes(AbstractSession session)
protected ForeignKeyConstraint buildForeignKeyConstraint(FieldDefinition field, DatabasePlatform platform)
protected ForeignKeyConstraint buildForeignKeyConstraint(java.util.Vector fkFieldNames, java.util.Vector pkFieldNames, TableDefinition targetTable, DatabasePlatform platform)
protected java.lang.String buildForeignKeyConstraintName(java.lang.String tableName, java.lang.String fieldName, int maximumNameLength)
protected UniqueKeyConstraint buildUniqueKeyConstraint(java.lang.String[] fieldNames, int serialNumber, DatabasePlatform platform)
protected java.lang.String buildUniqueKeyConstraintName(java.lang.String tableName, int serialNumber, int maximumNameLength)
public java.lang.Object clone()
clone
in class DatabaseObjectDefinition
public void createConstraints(AbstractSession session, java.io.Writer schemaWriter) throws TopLinkException
TopLinkException
public void createConstraintsOnDatabase(AbstractSession session) throws TopLinkException
TopLinkException
public java.lang.String deletionStringFor(DatabaseAccessor accessor)
public void dropConstraints(AbstractSession session, java.io.Writer schemaWriter) throws TopLinkException
TopLinkException
public void dropConstraintsOnDatabase(AbstractSession session) throws TopLinkException
TopLinkException
public java.util.Vector getFields()
public java.util.Vector<ForeignKeyConstraint> getForeignKeys()
public java.util.Vector<UniqueKeyConstraint> getUniqueKeys()
public java.util.Vector getPrimaryKeyFieldNames()
public void setFields(java.util.Vector fields)
public void setForeignKeys(java.util.Vector<ForeignKeyConstraint> foreignKeys)
public void setUniqueKeys(java.util.Vector<UniqueKeyConstraint> uniqueKeys)
public void setCreateSQLFiles(boolean genFlag)