public class SchemaManager
extends java.lang.Object
Purpose: Define all user level protocol for development time database manipulation.
Responsibilities:
Modifier and Type | Field and Description |
---|---|
protected java.io.Writer |
createSchemaWriter |
protected boolean |
createSQLFiles |
protected TableCreator |
defaultTableCreator |
protected java.io.Writer |
dropSchemaWriter |
protected DatabaseSessionImpl |
session |
Constructor and Description |
---|
SchemaManager(DatabaseSession session) |
SchemaManager(DatabaseSessionImpl session) |
Modifier and Type | Method and Description |
---|---|
void |
alterSequence(SequenceDefinition sequenceDefinition)
Use the definition to alter sequence.
|
void |
appendToDDLWriter(java.lang.String stringToWrite)
PUBLIC: If the schema manager is writing to a writer, append this string
to that writer.
|
void |
appendToDDLWriter(java.io.Writer schemaWriter,
java.lang.String stringToWrite) |
void |
buildFieldTypes(TableDefinition tableDef)
INTERNAL:
builds the field names based on the type read in from the builder
|
protected SequenceDefinition |
buildSequenceDefinition(Sequence sequence) |
void |
closeDDLWriter()
PUBLIC:
Close the schema writer.
|
void |
closeDDLWriter(java.io.Writer schemaWriter) |
void |
createConstraints(TableDefinition tableDefinition)
Use the table definition to add the constraints to the database, this is normally done
in two steps to avoid dependencies.
|
void |
createDefaultTables()
Create the default table schema for the TopLink project this session associated with.
|
void |
createObject(DatabaseObjectDefinition databaseObjectDefinition)
Use the definition object to create the schema entity on the database.
|
protected void |
createOrReplaceSequences(boolean create)
Common implementor for createSequence and replaceSequence
|
protected void |
createOrReplaceSequences(boolean create,
boolean drop)
Common implementor for createSequence and replaceSequence
|
void |
createSequences()
Create all the receiver's sequences on the database for all of the loaded descriptors.
|
void |
dropConstraints(TableDefinition tableDefinition)
Use the table definition to drop the constraints from the table, this is normally done
in two steps to avoid dependencies.
|
void |
dropObject(DatabaseObjectDefinition databaseObjectDefinition)
Use the definition object to drop the schema entity from the database.
|
void |
dropTable(java.lang.String tableName)
Drop (delete) the table named tableName from the database.
|
void |
finalize()
INTERNAL:
Close the schema writer when the schema manger is garbage collected
|
protected DatabaseAccessor |
getAccessor()
Return the appropriate accessor.
|
java.util.Vector |
getAllColumnNames(java.lang.String tableName)
Get a description of table columns available in a catalog.
|
java.util.Vector |
getAllColumnNames(java.lang.String creatorName,
java.lang.String tableName)
Get a description of table columns available in a catalog.
|
java.util.Vector |
getAllTableNames()
Get a description of tables available in a catalog.
|
java.util.Vector |
getAllTableNames(java.lang.String creatorName)
Get a description of table columns available in a catalog.
|
java.util.Vector |
getColumnInfo(java.lang.String catalog,
java.lang.String schema,
java.lang.String tableName,
java.lang.String columnName)
Get a description of table columns available in a catalog.
|
protected TableCreator |
getDefaultTableCreator()
Construct the default TableCreator.
|
protected java.io.Writer |
getDropSchemaWriter() |
AbstractSession |
getSession() |
java.util.Vector |
getTableInfo(java.lang.String catalog,
java.lang.String schema,
java.lang.String tableName,
java.lang.String[] types)
Get a description of tables available in a catalog.
|
void |
outputCreateDDLToFile(java.lang.String fileName) |
void |
outputCreateDDLToWriter(java.io.Writer createWriter) |
void |
outputDDLToDatabase()
PUBLIC:
Output all DDL statements directly to the database.
|
void |
outputDDLToFile(java.lang.String fileName)
PUBLIC:
Output all DDL statements to a file writer specified by the name in the parameter.
|
void |
outputDDLToWriter(java.io.Writer schemaWriter)
PUBLIC:
Output all DDL statements to a writer specified in the parameter.
|
void |
outputDropDDLToFile(java.lang.String fileName) |
void |
outputDropDDLToWriter(java.io.Writer dropWriter) |
void |
replaceDefaultTables()
Drop and recreate the default table schema for the TopLink project this session associated with.
|
void |
replaceDefaultTables(boolean keepSequenceTables)
Drop and recreate the default table schema for the TopLink project this session associated with.
|
void |
replaceObject(DatabaseObjectDefinition databaseDefinition)
Use the definition object to drop and recreate the schema entity on the database.
|
void |
replaceSequences()
Drop and recreate all the receiver's sequences on the database for all of the loaded descriptors.
|
void |
setCreateSQLFiles(boolean genFlag) |
void |
setSession(DatabaseSessionImpl session) |
boolean |
shouldWriteToDatabase()
PUBLIC:
Return true if this SchemaManager should write to the database directly
|
protected DatabaseSessionImpl session
protected java.io.Writer createSchemaWriter
protected java.io.Writer dropSchemaWriter
protected boolean createSQLFiles
protected TableCreator defaultTableCreator
public SchemaManager(DatabaseSessionImpl session)
public SchemaManager(DatabaseSession session)
protected java.io.Writer getDropSchemaWriter()
public void appendToDDLWriter(java.lang.String stringToWrite)
public void appendToDDLWriter(java.io.Writer schemaWriter, java.lang.String stringToWrite)
public void buildFieldTypes(TableDefinition tableDef)
public void closeDDLWriter()
public void closeDDLWriter(java.io.Writer schemaWriter)
public void createConstraints(TableDefinition tableDefinition) throws TopLinkException
TopLinkException
public void createObject(DatabaseObjectDefinition databaseObjectDefinition) throws TopLinkException
TopLinkException
public void createSequences() throws TopLinkException
TopLinkException
public void replaceSequences() throws TopLinkException
TopLinkException
protected void createOrReplaceSequences(boolean create) throws TopLinkException
TopLinkException
protected void createOrReplaceSequences(boolean create, boolean drop) throws TopLinkException
TopLinkException
protected SequenceDefinition buildSequenceDefinition(Sequence sequence)
public void dropConstraints(TableDefinition tableDefinition) throws TopLinkException
TopLinkException
public void dropObject(DatabaseObjectDefinition databaseObjectDefinition) throws TopLinkException
TopLinkException
public void dropTable(java.lang.String tableName) throws TopLinkException
TopLinkException
public void finalize()
finalize
in class java.lang.Object
protected DatabaseAccessor getAccessor()
public java.util.Vector getAllColumnNames(java.lang.String tableName) throws DatabaseException
Each column description has the following columns:
tableName
- a table name patternDatabaseException
public java.util.Vector getAllColumnNames(java.lang.String creatorName, java.lang.String tableName) throws DatabaseException
Each column description has the following columns:
creatorName
- a schema name pattern; "" retrieves those
without a schematableName
- a table name patternDatabaseException
public java.util.Vector getAllTableNames() throws DatabaseException
Each table description has the following columns:
Note: Some databases may not return information for all tables.
DatabaseException
public java.util.Vector getAllTableNames(java.lang.String creatorName) throws DatabaseException
Each column description has the following columns:
creatorName
- a schema name pattern; "" retrieves those
without a schemaDatabaseException
public java.util.Vector getColumnInfo(java.lang.String catalog, java.lang.String schema, java.lang.String tableName, java.lang.String columnName) throws DatabaseException
Only column descriptions matching the catalog, schema, table and column name criteria are returned. They are ordered by TABLE_SCHEM, TABLE_NAME and ORDINAL_POSITION.
Each column description has the following columns:
catalog
- a catalog name; "" retrieves those without a
catalog; null means drop catalog name from the selection criteriaschemaPattern
- a schema name pattern; "" retrieves those
without a schematableNamePattern
- a table name patterncolumnNamePattern
- a column name patternDatabaseException
public AbstractSession getSession()
public java.util.Vector getTableInfo(java.lang.String catalog, java.lang.String schema, java.lang.String tableName, java.lang.String[] types) throws DatabaseException
Only table descriptions matching the catalog, schema, table name and type criteria are returned. They are ordered by TABLE_TYPE, TABLE_SCHEM and TABLE_NAME.
Each table description has the following columns:
Note: Some databases may not return information for all tables.
catalog
- a catalog name; "" retrieves those without a
catalog; null means drop catalog name from the selection criteriaschemaPattern
- a schema name pattern; "" retrieves those
without a schematableNamePattern
- a table name patterntypes
- a list of table types to include; null returns all typesDatabaseException
public void outputDDLToDatabase()
public void outputDDLToFile(java.lang.String fileName)
public void outputCreateDDLToFile(java.lang.String fileName)
public void outputDropDDLToFile(java.lang.String fileName)
public void outputDDLToWriter(java.io.Writer schemaWriter)
public void outputCreateDDLToWriter(java.io.Writer createWriter)
public void outputDropDDLToWriter(java.io.Writer dropWriter)
public void replaceObject(DatabaseObjectDefinition databaseDefinition) throws TopLinkException
TopLinkException
protected TableCreator getDefaultTableCreator()
public void createDefaultTables()
public void replaceDefaultTables() throws TopLinkException
TopLinkException
public void replaceDefaultTables(boolean keepSequenceTables) throws TopLinkException
TopLinkException
public void setSession(DatabaseSessionImpl session)
public boolean shouldWriteToDatabase()
public void alterSequence(SequenceDefinition sequenceDefinition) throws TopLinkException
TopLinkException
public void setCreateSQLFiles(boolean genFlag)