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