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 |
---|---|
static boolean |
FAST_TABLE_CREATOR
Allow table creator to occur "fast" by just deleting all the rows.
|
static boolean |
FORCE_DROP
Allow replacing of table to force the drop, this may require several passes.
|
Constructor and Description |
---|
SchemaManager(DatabaseSession session) |
SchemaManager(org.eclipse.persistence.internal.sessions.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
|
boolean |
checkTableExists(TableDefinition table)
Check if the table exists by issuing a select.
|
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(boolean generateFKConstraints)
Create the default table schema for the project this session associated with.
|
void |
createObject(DatabaseObjectDefinition databaseObjectDefinition)
Use the definition object to create the schema entity on the database.
|
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 |
dropDatabaseSchemas()
INTERNAL: Iterate over the schemas that need to be dropped.
|
void |
dropDefaultTables()
Create the default table schema for the project this session associated with.
|
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 |
extendDefaultTables(boolean generateFKConstraints)
Create or extend the default table schema for the project this session associated with.
|
void |
finalize()
INTERNAL: Close the schema writer when the schema manger is garbage collected
|
void |
generateStoredProcedures()
PUBLIC: Use this method to generate stored procedures based on the dynamic SQL generated for your mappings and descriptors.
|
void |
generateStoredProcedures(java.io.Writer writer)
PUBLIC: Use this method to generate stored procedures based on the dynamic SQL generated for your mappings and descriptors.
|
void |
generateStoredProceduresAndAmendmentClass(java.lang.String path, java.lang.String fullyQualifiedClassName)
PUBLIC: Use this method to generate stored procedures based on the dynamic SQL generated for your mappings and descriptors.
|
void |
generateStoredProceduresAndAmendmentClass(java.io.Writer writer, java.lang.String fullyQualifiedClassName)
PUBLIC: Use this method to generate stored procedures based on the dynamic SQL generated for your mappings and descriptors.
|
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.
|
org.eclipse.persistence.internal.sessions.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 project this session associated with.
|
void |
replaceDefaultTables(boolean createSequenceTables, boolean generateFKConstraints)
Drop and recreate the default table schema for the project this session associated with.
|
void |
replaceDefaultTables(boolean createSequenceTables, boolean createSequences, boolean generateFKConstraints)
Drop and recreate the default table schema for the 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 |
setCreateDatabaseSchemas(boolean createDatabaseSchemas)
INTERNAL: Set to true if database schemas should be built during the DDL generation.
|
void |
setCreateSQLFiles(boolean genFlag) |
void |
setSession(org.eclipse.persistence.internal.sessions.DatabaseSessionImpl session) |
boolean |
shouldWriteToDatabase()
PUBLIC: Return true if this SchemaManager should write to the database directly
|
public static boolean FAST_TABLE_CREATOR
public static boolean FORCE_DROP
public SchemaManager(org.eclipse.persistence.internal.sessions.DatabaseSessionImpl session)
public SchemaManager(DatabaseSession session)
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 EclipseLinkException
EclipseLinkException
public void createObject(DatabaseObjectDefinition databaseObjectDefinition) throws EclipseLinkException
EclipseLinkException
public void createSequences() throws EclipseLinkException
EclipseLinkException
public void setCreateDatabaseSchemas(boolean createDatabaseSchemas)
public void setCreateSQLFiles(boolean genFlag)
public void replaceSequences() throws EclipseLinkException
EclipseLinkException
public boolean checkTableExists(TableDefinition table)
public void dropConstraints(TableDefinition tableDefinition) throws EclipseLinkException
EclipseLinkException
public void dropObject(DatabaseObjectDefinition databaseObjectDefinition) throws EclipseLinkException
EclipseLinkException
public void dropTable(java.lang.String tableName) throws EclipseLinkException
EclipseLinkException
public void finalize()
finalize
in class java.lang.Object
public void generateStoredProcedures() throws EclipseLinkException
EclipseLinkException
public void generateStoredProcedures(java.io.Writer writer) throws EclipseLinkException
EclipseLinkException
public void generateStoredProceduresAndAmendmentClass(java.io.Writer writer, java.lang.String fullyQualifiedClassName) throws EclipseLinkException
EclipseLinkException
public void generateStoredProceduresAndAmendmentClass(java.lang.String path, java.lang.String fullyQualifiedClassName) throws EclipseLinkException
EclipseLinkException
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 criteriaschema
- a schema name pattern; "" retrieves those without a schematableName
- a table name patterncolumnName
- a column name patternDatabaseException
public org.eclipse.persistence.internal.sessions.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 criteriaschema
- a schema name pattern; "" retrieves those without a schematableName
- 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 EclipseLinkException
EclipseLinkException
public void createDefaultTables(boolean generateFKConstraints)
public void dropDatabaseSchemas()
public void dropDefaultTables()
public void replaceDefaultTables() throws EclipseLinkException
EclipseLinkException
public void replaceDefaultTables(boolean createSequenceTables, boolean generateFKConstraints) throws EclipseLinkException
EclipseLinkException
public void replaceDefaultTables(boolean createSequenceTables, boolean createSequences, boolean generateFKConstraints) throws EclipseLinkException
EclipseLinkException
public void setSession(org.eclipse.persistence.internal.sessions.DatabaseSessionImpl session)
public boolean shouldWriteToDatabase()
public void alterSequence(SequenceDefinition sequenceDefinition) throws EclipseLinkException
EclipseLinkException
public void extendDefaultTables(boolean generateFKConstraints) throws EclipseLinkException
EclipseLinkException