public class TableDefinition extends DatabaseObjectDefinition
Purpose: Allow a generic way of creating tables on the different platforms.
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 |
addIndex(IndexDefinition index)
PUBLIC:
Add an index to the table.
|
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(org.eclipse.persistence.internal.sessions.AbstractSession session,
ForeignKeyConstraint foreignKey,
Writer writer)
INTERNAL:
Return the alter table statement to add the constraints.
|
Writer |
buildConstraintDeletionWriter(org.eclipse.persistence.internal.sessions.AbstractSession session,
ForeignKeyConstraint foreignKey,
Writer writer)
INTERNAL:
Return the alter table statement to drop the constraints.
|
Writer |
buildCreationWriter(org.eclipse.persistence.internal.sessions.AbstractSession session,
Writer writer)
INTERNAL:
Return the create table statement.
|
Writer |
buildDeletionWriter(org.eclipse.persistence.internal.sessions.AbstractSession session,
Writer writer)
INTERNAL:
Return the drop table statement.
|
IndexDefinition |
buildIndex(org.eclipse.persistence.internal.sessions.AbstractSession session,
String key,
List<String> columnNames,
boolean isUniqueSetOnField)
INTERNAL:
Return the index creation statement.
|
Writer |
buildIndexDeletionWriter(org.eclipse.persistence.internal.sessions.AbstractSession session,
String key,
Writer writer,
boolean isUniqueSetOnField)
INTERNAL:
Return the index drop statement.
|
Writer |
buildUniqueConstraintCreationWriter(org.eclipse.persistence.internal.sessions.AbstractSession session,
UniqueKeyConstraint uniqueKey,
Writer writer)
INTERNAL:
Return the alter table statement to add the constraints.
|
Writer |
buildUniqueConstraintDeletionWriter(org.eclipse.persistence.internal.sessions.AbstractSession session,
UniqueKeyConstraint uniqueKey,
Writer writer)
INTERNAL:
Return the alter table statement to drop the constraints.
|
Writer |
buildVPDCreationFunctionWriter(org.eclipse.persistence.internal.sessions.AbstractSession session,
Writer writer)
INTERNAL:
|
Writer |
buildVPDCreationPolicyWriter(org.eclipse.persistence.internal.sessions.AbstractSession session,
Writer writer)
INTERNAL:
|
Writer |
buildVPDDeletionWriter(org.eclipse.persistence.internal.sessions.AbstractSession session,
Writer writer)
INTERNAL:
|
Object |
clone()
PUBLIC:
Performs a deep copy of this table definition.
|
void |
createConstraints(org.eclipse.persistence.internal.sessions.AbstractSession session,
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 |
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. |
String |
deletionStringFor(org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor accessor)
INTERNAL:
Return the delete SQL string.
|
void |
dropConstraints(org.eclipse.persistence.internal.sessions.AbstractSession session,
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 |
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. |
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.
|
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:
|
List<UniqueKeyConstraint> |
getUniqueKeys()
PUBLIC:
|
void |
postCreateObject(org.eclipse.persistence.internal.sessions.AbstractSession session,
Writer createSchemaWriter,
boolean createSQLFiles)
Execute any statements required after the creation of the object
|
void |
preDropObject(org.eclipse.persistence.internal.sessions.AbstractSession session,
Writer dropSchemaWriter,
boolean createSQLFiles)
Execute any statements required before the deletion of the object
|
void |
setCreateSQLFiles(boolean genFlag)
PUBLIC:
|
void |
setCreateVPDCalls(boolean createVPDCalls,
String tenantFieldName)
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(List<FieldDefinition> fields)
PUBLIC:
|
void |
setForeignKeyMap(Map<String,ForeignKeyConstraint> foreignKeyMap)
INTERNAL:
|
void |
setForeignKeys(List<ForeignKeyConstraint> foreignKeys)
PUBLIC:
Set the ForeignKeyConstraint list.
|
void |
setIndexes(List<IndexDefinition> indexes)
PUBLIC:
|
void |
setUniqueKeys(List<UniqueKeyConstraint> uniqueKeys)
PUBLIC:
|
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,
Writer writer) |
createObject, createOnDatabase, dropFromDatabase, dropObject, getFullName, getName, getQualifier, setName, setQualifier, toString
public void addField(String fieldName, Class type)
type
- is the Java class type corresponding to the database type.public void addField(String fieldName, Class type, int fieldSize)
type
- is the Java class type corresponding to the database type.public void addField(String fieldName, Class type, int fieldSize, int fieldSubSize)
type
- is the Java class type corresponding 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 addIndex(IndexDefinition index)
public void addIdentityField(String fieldName, Class type)
type
- is the Java class type corresponding to the database type.public void addIdentityField(String fieldName, Class type, int fieldSize)
type
- is the Java class type corresponding to the database type.public void addPrimaryKeyField(String fieldName, Class type)
type
- is the Java class type corresponding to the database type.public void addPrimaryKeyField(String fieldName, Class type, int fieldSize)
type
- is the Java class type corresponding to the database type.public Writer buildConstraintCreationWriter(org.eclipse.persistence.internal.sessions.AbstractSession session, ForeignKeyConstraint foreignKey, Writer writer) throws ValidationException
ValidationException
public Writer buildConstraintDeletionWriter(org.eclipse.persistence.internal.sessions.AbstractSession session, ForeignKeyConstraint foreignKey, Writer writer) throws ValidationException
ValidationException
public Writer buildUniqueConstraintCreationWriter(org.eclipse.persistence.internal.sessions.AbstractSession session, UniqueKeyConstraint uniqueKey, Writer writer) throws ValidationException
ValidationException
public Writer buildUniqueConstraintDeletionWriter(org.eclipse.persistence.internal.sessions.AbstractSession session, UniqueKeyConstraint uniqueKey, Writer writer) throws ValidationException
ValidationException
public IndexDefinition buildIndex(org.eclipse.persistence.internal.sessions.AbstractSession session, String key, List<String> columnNames, boolean isUniqueSetOnField)
public Writer buildIndexDeletionWriter(org.eclipse.persistence.internal.sessions.AbstractSession session, String key, Writer writer, boolean isUniqueSetOnField)
public String getCreationPrefix()
public void setCreationPrefix(String creationPrefix)
public String getCreationSuffix()
public void setCreationSuffix(String creationSuffix)
public Writer buildCreationWriter(org.eclipse.persistence.internal.sessions.AbstractSession session, Writer writer) throws ValidationException
buildCreationWriter
in class DatabaseObjectDefinition
ValidationException
public Writer buildDeletionWriter(org.eclipse.persistence.internal.sessions.AbstractSession session, Writer writer) throws ValidationException
buildDeletionWriter
in class DatabaseObjectDefinition
ValidationException
public Writer buildVPDCreationPolicyWriter(org.eclipse.persistence.internal.sessions.AbstractSession session, Writer writer)
buildVPDCreationPolicyWriter
in class DatabaseObjectDefinition
public Writer buildVPDCreationFunctionWriter(org.eclipse.persistence.internal.sessions.AbstractSession session, Writer writer)
buildVPDCreationFunctionWriter
in class DatabaseObjectDefinition
public Writer buildVPDDeletionWriter(org.eclipse.persistence.internal.sessions.AbstractSession session, Writer writer)
buildVPDDeletionWriter
in class DatabaseObjectDefinition
public Object clone()
clone
in class DatabaseObjectDefinition
public void createConstraints(org.eclipse.persistence.internal.sessions.AbstractSession session, Writer schemaWriter) throws EclipseLinkException
EclipseLinkException
public void createConstraintsOnDatabase(org.eclipse.persistence.internal.sessions.AbstractSession session) throws EclipseLinkException
EclipseLinkException
public void createIndexes(org.eclipse.persistence.internal.sessions.AbstractSession session, Writer writer)
ValidationException
- wraps any IOException from the writerpublic void writeLineSeperator(org.eclipse.persistence.internal.sessions.AbstractSession session, Writer writer)
public String deletionStringFor(org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor accessor)
public void dropConstraints(org.eclipse.persistence.internal.sessions.AbstractSession session, Writer schemaWriter) throws EclipseLinkException
EclipseLinkException
public void dropConstraintsOnDatabase(org.eclipse.persistence.internal.sessions.AbstractSession session) throws EclipseLinkException
EclipseLinkException
public void dropIndexes(org.eclipse.persistence.internal.sessions.AbstractSession session, Writer writer)
ValidationException
- wraps any IOException from the writerpublic Map<String,ForeignKeyConstraint> getForeignKeyMap()
public void setForeignKeyMap(Map<String,ForeignKeyConstraint> foreignKeyMap)
public List<FieldDefinition> getFields()
public Collection<ForeignKeyConstraint> getForeignKeys()
public List<UniqueKeyConstraint> getUniqueKeys()
public void setIndexes(List<IndexDefinition> indexes)
public void setCreateVPDCalls(boolean createVPDCalls, String tenantFieldName)
public List<IndexDefinition> getIndexes()
public void postCreateObject(org.eclipse.persistence.internal.sessions.AbstractSession session, Writer createSchemaWriter, boolean createSQLFiles)
postCreateObject
in class DatabaseObjectDefinition
session
- createSchemaWriter
- public void preDropObject(org.eclipse.persistence.internal.sessions.AbstractSession session, Writer dropSchemaWriter, boolean createSQLFiles)
preDropObject
in class DatabaseObjectDefinition
session
- dropSchemaWriter
- public void setFields(List<FieldDefinition> fields)
public void setForeignKeys(List<ForeignKeyConstraint> foreignKeys)
public void setUniqueKeys(List<UniqueKeyConstraint> uniqueKeys)
public boolean shouldCreateVPDCalls(org.eclipse.persistence.internal.sessions.AbstractSession session)
shouldCreateVPDCalls
in class DatabaseObjectDefinition
public void setCreateSQLFiles(boolean genFlag)
EclipseLink 2.3.2, "build v20111125-r10461" API Reference