Oracle Fusion Middleware Java API Reference for Oracle TopLink (Deprecated)
11g Release 1 (11.1.1)

B32476-04

oracle.toplink.tools.schemaframework
Class SchemaManager

java.lang.Object
  extended by oracle.toplink.tools.schemaframework.SchemaManager
Direct Known Subclasses:
XMLSchemaManager

public class SchemaManager
extends java.lang.Object

Purpose: Define all user level protocol for development time database manipulation.

Responsibilities:


Field Summary
static boolean FAST_TABLE_CREATOR
          Allow table creator to occur "fast" by just deleting all the rows.
 
Constructor Summary
SchemaManager(DatabaseSession session)
           
SchemaManager(oracle.toplink.internal.sessions.DatabaseSessionImpl session)
           
 
Method Summary
 void alterSequence(SequenceDefinition sequenceDefinition)
          Use the definition to alter sequence.
 void appendToDDLWriter(java.lang.String stringToWrite)
          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 closeDDLWriter()
          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 TopLink 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 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 generateStoredProcedures()
          Use this method to generate stored procedures based on the dynamic SQL generated for your mappings and descriptors.
 void generateStoredProcedures(java.io.Writer writer)
          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)
          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)
          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.
 oracle.toplink.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()
          Output all DDL statements directly to the database.
 void outputDDLToFile(java.lang.String fileName)
          Output all DDL statements to a file writer specified by the name in the parameter.
 void outputDDLToWriter(java.io.Writer schemaWriter)
          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, boolean generateFKConstraints)
          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(oracle.toplink.internal.sessions.DatabaseSessionImpl session)
           
 boolean shouldWriteToDatabase()
          Return true if this SchemaManager should write to the database directly
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FAST_TABLE_CREATOR

public static boolean FAST_TABLE_CREATOR
Description copied from class: SchemaManager
Allow table creator to occur "fast" by just deleting all the rows.

Constructor Detail

SchemaManager

public SchemaManager(oracle.toplink.internal.sessions.DatabaseSessionImpl session)

SchemaManager

public SchemaManager(DatabaseSession session)
Method Detail

appendToDDLWriter

public void appendToDDLWriter(java.lang.String stringToWrite)
If the schema manager is writing to a writer, append this string to that writer.


appendToDDLWriter

public void appendToDDLWriter(java.io.Writer schemaWriter,
                              java.lang.String stringToWrite)

closeDDLWriter

public void closeDDLWriter()
Close the schema writer.


closeDDLWriter

public void closeDDLWriter(java.io.Writer schemaWriter)

createConstraints

public void createConstraints(TableDefinition tableDefinition)
                       throws TopLinkException
Use the table definition to add the constraints to the database, this is normally done in two steps to avoid dependencies.

Throws:
TopLinkException

createObject

public void createObject(DatabaseObjectDefinition databaseObjectDefinition)
                  throws TopLinkException
Use the definition object to create the schema entity on the database. This is used for creating tables, views, procedures ... etc ...

Throws:
TopLinkException

createSequences

public void createSequences()
                     throws TopLinkException
Create all the receiver's sequences on the database for all of the loaded descriptors.

Throws:
TopLinkException

setCreateSQLFiles

public void setCreateSQLFiles(boolean genFlag)

replaceSequences

public void replaceSequences()
                      throws TopLinkException
Drop and recreate all the receiver's sequences on the database for all of the loaded descriptors.

Throws:
TopLinkException

dropConstraints

public void dropConstraints(TableDefinition tableDefinition)
                     throws TopLinkException
Use the table definition to drop the constraints from the table, this is normally done in two steps to avoid dependencies.

Throws:
TopLinkException

dropObject

public void dropObject(DatabaseObjectDefinition databaseObjectDefinition)
                throws TopLinkException
Use the definition object to drop the schema entity from the database. This is used for droping tables, views, procedures ... etc ...

Throws:
TopLinkException

dropTable

public void dropTable(java.lang.String tableName)
               throws TopLinkException
Drop (delete) the table named tableName from the database.

Throws:
TopLinkException

generateStoredProcedures

public void generateStoredProcedures()
                              throws TopLinkException
Use this method to generate stored procedures based on the dynamic SQL generated for your mappings and descriptors. This should be used with caution as it maintenance will be high. Stored procedures may be generated either directly on the database or to a file.

Throws:
TopLinkException

generateStoredProcedures

public void generateStoredProcedures(java.io.Writer writer)
                              throws TopLinkException
Use this method to generate stored procedures based on the dynamic SQL generated for your mappings and descriptors. This should be used with caution as it maintenance will be high. Stored procedures may be generated either directly on the database or to a file.

Throws:
TopLinkException

generateStoredProceduresAndAmendmentClass

public void generateStoredProceduresAndAmendmentClass(java.io.Writer writer,
                                                      java.lang.String fullyQualifiedClassName)
                                               throws TopLinkException
Use this method to generate stored procedures based on the dynamic SQL generated for your mappings and descriptors. This should be used with caution as it maintenance will be high. Stored procedures may be generated either directly on the database or to a file.

Throws:
TopLinkException

generateStoredProceduresAndAmendmentClass

public void generateStoredProceduresAndAmendmentClass(java.lang.String path,
                                                      java.lang.String fullyQualifiedClassName)
                                               throws TopLinkException
Use this method to generate stored procedures based on the dynamic SQL generated for your mappings and descriptors. This should be used with caution as it maintenance will be high. Stored procedures may be generated either directly on the database or to a file.

Throws:
TopLinkException

getAllColumnNames

public java.util.Vector getAllColumnNames(java.lang.String tableName)
                                   throws DatabaseException
Get a description of table columns available in a catalog.

Each column description has the following columns:

  1. TABLE_CAT String => table catalog (may be null)
  2. TABLE_SCHEM String => table schema (may be null)
  3. TABLE_NAME String => table name
  4. COLUMN_NAME String => column name
  5. DATA_TYPE short => SQL type from java.sql.Types
  6. TYPE_NAME String => Data source dependent type name
  7. COLUMN_SIZE int => column size. For char or date types this is the maximum number of characters, for numeric or decimal types this is precision.
  8. BUFFER_LENGTH is not used.
  9. DECIMAL_DIGITS int => the number of fractional digits
  10. NUM_PREC_RADIX int => Radix (typically either 10 or 2)
  11. NULLABLE int => is NULL allowed?
    • columnNoNulls - might not allow NULL values
    • columnNullable - definitely allows NULL values
    • columnNullableUnknown - nullability unknown
  12. REMARKS String => comment describing column (may be null)
  13. COLUMN_DEF String => default value (may be null)
  14. SQL_DATA_TYPE int => unused
  15. SQL_DATETIME_SUB int => unused
  16. CHAR_OCTET_LENGTH int => for char types the maximum number of bytes in the column
  17. ORDINAL_POSITION int => index of column in table (starting at 1)
  18. IS_NULLABLE String => "NO" means column definitely does not allow NULL values; "YES" means the column might allow NULL values. An empty string means nobody knows.

Parameters:
tableName - a table name pattern
Returns:
a Vector of Records.
Throws:
DatabaseException

getAllColumnNames

public java.util.Vector getAllColumnNames(java.lang.String creatorName,
                          java.lang.String tableName)
                                   throws DatabaseException
Get a description of table columns available in a catalog.

Each column description has the following columns:

  1. TABLE_CAT String => table catalog (may be null)
  2. TABLE_SCHEM String => table schema (may be null)
  3. TABLE_NAME String => table name
  4. COLUMN_NAME String => column name
  5. DATA_TYPE short => SQL type from java.sql.Types
  6. TYPE_NAME String => Data source dependent type name
  7. COLUMN_SIZE int => column size. For char or date types this is the maximum number of characters, for numeric or decimal types this is precision.
  8. BUFFER_LENGTH is not used.
  9. DECIMAL_DIGITS int => the number of fractional digits
  10. NUM_PREC_RADIX int => Radix (typically either 10 or 2)
  11. NULLABLE int => is NULL allowed?
    • columnNoNulls - might not allow NULL values
    • columnNullable - definitely allows NULL values
    • columnNullableUnknown - nullability unknown
  12. REMARKS String => comment describing column (may be null)
  13. COLUMN_DEF String => default value (may be null)
  14. SQL_DATA_TYPE int => unused
  15. SQL_DATETIME_SUB int => unused
  16. CHAR_OCTET_LENGTH int => for char types the maximum number of bytes in the column
  17. ORDINAL_POSITION int => index of column in table (starting at 1)
  18. IS_NULLABLE String => "NO" means column definitely does not allow NULL values; "YES" means the column might allow NULL values. An empty string means nobody knows.

Parameters:
creatorName - a schema name pattern; "" retrieves those without a schema
tableName - a table name pattern
Returns:
a Vector of Records.
Throws:
DatabaseException

getAllTableNames

public java.util.Vector getAllTableNames()
                                  throws DatabaseException
Get a description of tables available in a catalog.

Each table description has the following columns:

  1. TABLE_CAT String => table catalog (may be null)
  2. TABLE_SCHEM String => table schema (may be null)
  3. TABLE_NAME String => table name
  4. TABLE_TYPE String => table type. Typical types are "TABLE", "VIEW", "SYSTEM TABLE", "GLOBAL TEMPORARY", "LOCAL TEMPORARY", "ALIAS", "SYNONYM".
  5. REMARKS String => explanatory comment on the table

Note: Some databases may not return information for all tables.

Returns:
a Vector of Records.
Throws:
DatabaseException

getAllTableNames

public java.util.Vector getAllTableNames(java.lang.String creatorName)
                                  throws DatabaseException
Get a description of table columns available in a catalog.

Each column description has the following columns:

  1. TABLE_CAT String => table catalog (may be null)
  2. TABLE_SCHEM String => table schema (may be null)
  3. TABLE_NAME String => table name
  4. COLUMN_NAME String => column name
  5. DATA_TYPE short => SQL type from java.sql.Types
  6. TYPE_NAME String => Data source dependent type name
  7. COLUMN_SIZE int => column size. For char or date types this is the maximum number of characters, for numeric or decimal types this is precision.
  8. BUFFER_LENGTH is not used.
  9. DECIMAL_DIGITS int => the number of fractional digits
  10. NUM_PREC_RADIX int => Radix (typically either 10 or 2)
  11. NULLABLE int => is NULL allowed?
    • columnNoNulls - might not allow NULL values
    • columnNullable - definitely allows NULL values
    • columnNullableUnknown - nullability unknown
  12. REMARKS String => comment describing column (may be null)
  13. COLUMN_DEF String => default value (may be null)
  14. SQL_DATA_TYPE int => unused
  15. SQL_DATETIME_SUB int => unused
  16. CHAR_OCTET_LENGTH int => for char types the maximum number of bytes in the column
  17. ORDINAL_POSITION int => index of column in table (starting at 1)
  18. IS_NULLABLE String => "NO" means column definitely does not allow NULL values; "YES" means the column might allow NULL values. An empty string means nobody knows.

Parameters:
creatorName - a schema name pattern; "" retrieves those without a schema
Returns:
a Vector of Records.
Throws:
DatabaseException

getColumnInfo

public java.util.Vector getColumnInfo(java.lang.String catalog,
                      java.lang.String schema,
                      java.lang.String tableName,
                      java.lang.String columnName)
                               throws DatabaseException
Get a description of table columns available in a catalog.

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:

  1. TABLE_CAT String => table catalog (may be null)
  2. TABLE_SCHEM String => table schema (may be null)
  3. TABLE_NAME String => table name
  4. COLUMN_NAME String => column name
  5. DATA_TYPE short => SQL type from java.sql.Types
  6. TYPE_NAME String => Data source dependent type name
  7. COLUMN_SIZE int => column size. For char or date types this is the maximum number of characters, for numeric or decimal types this is precision.
  8. BUFFER_LENGTH is not used.
  9. DECIMAL_DIGITS int => the number of fractional digits
  10. NUM_PREC_RADIX int => Radix (typically either 10 or 2)
  11. NULLABLE int => is NULL allowed?
    • columnNoNulls - might not allow NULL values
    • columnNullable - definitely allows NULL values
    • columnNullableUnknown - nullability unknown
  12. REMARKS String => comment describing column (may be null)
  13. COLUMN_DEF String => default value (may be null)
  14. SQL_DATA_TYPE int => unused
  15. SQL_DATETIME_SUB int => unused
  16. CHAR_OCTET_LENGTH int => for char types the maximum number of bytes in the column
  17. ORDINAL_POSITION int => index of column in table (starting at 1)
  18. IS_NULLABLE String => "NO" means column definitely does not allow NULL values; "YES" means the column might allow NULL values. An empty string means nobody knows.

Parameters:
catalog - a catalog name; "" retrieves those without a catalog; null means drop catalog name from the selection criteria
schema - a schema name pattern; "" retrieves those without a schema
tableName - a table name pattern
columnName - a column name pattern
Returns:
a Vector of Records.
Throws:
DatabaseException

getSession

public oracle.toplink.internal.sessions.AbstractSession getSession()

getTableInfo

public java.util.Vector getTableInfo(java.lang.String catalog,
                     java.lang.String schema,
                     java.lang.String tableName,
                     java.lang.String[] types)
                              throws DatabaseException
Get a description of tables available in a catalog.

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:

  1. TABLE_CAT String => table catalog (may be null)
  2. TABLE_SCHEM String => table schema (may be null)
  3. TABLE_NAME String => table name
  4. TABLE_TYPE String => table type. Typical types are "TABLE", "VIEW", "SYSTEM TABLE", "GLOBAL TEMPORARY", "LOCAL TEMPORARY", "ALIAS", "SYNONYM".
  5. REMARKS String => explanatory comment on the table

Note: Some databases may not return information for all tables.

Parameters:
catalog - a catalog name; "" retrieves those without a catalog; null means drop catalog name from the selection criteria
schema - a schema name pattern; "" retrieves those without a schema
tableName - a table name pattern
types - a list of table types to include; null returns all types
Returns:
a Vector of Records.
Throws:
DatabaseException

outputDDLToDatabase

public void outputDDLToDatabase()
Output all DDL statements directly to the database.


outputDDLToFile

public void outputDDLToFile(java.lang.String fileName)
Output all DDL statements to a file writer specified by the name in the parameter.


outputCreateDDLToFile

public void outputCreateDDLToFile(java.lang.String fileName)

outputDropDDLToFile

public void outputDropDDLToFile(java.lang.String fileName)

outputDDLToWriter

public void outputDDLToWriter(java.io.Writer schemaWriter)
Output all DDL statements to a writer specified in the parameter.


outputCreateDDLToWriter

public void outputCreateDDLToWriter(java.io.Writer createWriter)

outputDropDDLToWriter

public void outputDropDDLToWriter(java.io.Writer dropWriter)

replaceObject

public void replaceObject(DatabaseObjectDefinition databaseDefinition)
                   throws TopLinkException
Use the definition object to drop and recreate the schema entity on the database. This is used for dropping tables, views, procedures ... etc ... This handles and ignore any database error while droping incase the object did not previously exist.

Throws:
TopLinkException

createDefaultTables

public void createDefaultTables(boolean generateFKConstraints)
Create the default table schema for the TopLink project this session associated with.


replaceDefaultTables

public void replaceDefaultTables()
                          throws TopLinkException
Drop and recreate the default table schema for the TopLink project this session associated with.

Throws:
TopLinkException

replaceDefaultTables

public void replaceDefaultTables(boolean keepSequenceTables,
                                 boolean generateFKConstraints)
                          throws TopLinkException
Drop and recreate the default table schema for the TopLink project this session associated with.

Throws:
TopLinkException

setSession

public void setSession(oracle.toplink.internal.sessions.DatabaseSessionImpl session)

shouldWriteToDatabase

public boolean shouldWriteToDatabase()
Return true if this SchemaManager should write to the database directly


alterSequence

public void alterSequence(SequenceDefinition sequenceDefinition)
                   throws TopLinkException
Use the definition to alter sequence.

Throws:
TopLinkException

Copyright © 1998, 2012, Oracle. All Rights Reserved.