public class SchemaGenerator extends Object
Schema
s matching the current
database. All schemas are added to the current SchemaGroup
.
Note that tables whose name starts with "OPENJPA_" will be not be added
to the database schema. This enables the creation of special tables
that will never be dropped by the SchemaTool
.Modifier and Type | Class and Description |
---|---|
static class |
SchemaGenerator.Event
An event corresponding to the generation of a schema object.
|
static interface |
SchemaGenerator.Listener
A listener for a potentially lengthy schema generation process.
|
Constructor and Description |
---|
SchemaGenerator(JDBCConfiguration conf)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addListener(SchemaGenerator.Listener l)
Adds a listener for schema generation events.
|
void |
generateForeignKeys(DBIdentifier schemaName,
DBIdentifier[] tableNames)
Generate foreign key information for the given schema.
|
void |
generateForeignKeys(DBIdentifier schemaName,
DBIdentifier tableName,
Connection conn,
DatabaseMetaData meta) |
void |
generateForeignKeys(String schemaName,
String[] tableNames)
Deprecated.
|
void |
generateForeignKeys(String schemaName,
String tableName,
Connection conn,
DatabaseMetaData meta)
Generates table foreign keys.
|
void |
generateIndexes(DBIdentifier schemaName,
DBIdentifier[] tableNames)
Generate index information for the given schema.
|
void |
generateIndexes(DBIdentifier schemaName,
DBIdentifier tableName,
Connection conn,
DatabaseMetaData meta) |
void |
generateIndexes(String schemaName,
String[] tableNames)
Deprecated.
|
void |
generateIndexes(String schemaName,
String tableName,
Connection conn,
DatabaseMetaData meta)
Deprecated.
|
void |
generatePrimaryKeys(DBIdentifier schemaName,
DBIdentifier[] tableNames)
Generate primary key information for the given schema.
|
void |
generatePrimaryKeys(DBIdentifier schemaName,
DBIdentifier tableName,
Connection conn,
DatabaseMetaData meta) |
void |
generatePrimaryKeys(String schemaName,
String[] tableNames)
Deprecated.
|
void |
generatePrimaryKeys(String schemaName,
String tableName,
Connection conn,
DatabaseMetaData meta)
Deprecated.
|
void |
generateSchema(DBIdentifier name,
DBIdentifier[] tableNames)
Add a fully-constructed
Schema matching the given database
schema to the current group. |
void |
generateSchema(String name,
String[] tableNames)
Deprecated.
|
void |
generateSchemas()
Generate all schemas set in the configuration.
|
void |
generateSchemas(DBIdentifier[] schemasAndTables)
Generate the schemas and/or tables named in the given strings.
|
void |
generateSchemas(String[] schemasAndTables)
Deprecated.
|
void |
generateSequences(DBIdentifier schemaName,
DBIdentifier sequenceName,
Connection conn,
DatabaseMetaData meta) |
void |
generateSequences(String schemaName,
String sequenceName,
Connection conn,
DatabaseMetaData meta)
Deprecated.
|
void |
generateTables(DBIdentifier schemaName,
DBIdentifier tableName,
Connection conn,
DatabaseMetaData meta)
Adds all tables matching the given name pattern to the schema.
|
void |
generateTables(String schemaName,
String tableName,
Connection conn,
DatabaseMetaData meta)
Deprecated.
|
boolean |
getForeignKeys()
Return whether foreign keys should be generated.
|
boolean |
getIndexes()
Return whether indexes should be generated.
|
boolean |
getOpenJPATables()
Whether to generate info on special tables used by OpenJPA components
for bookkeeping.
|
boolean |
getPrimaryKeys()
Return whether primary keys should be generated.
|
SchemaGroup |
getSchemaGroup()
Return the current schema group.
|
boolean |
getSequences()
Return whether sequences should be generated.
|
boolean |
removeListener(SchemaGenerator.Listener l)
Removes a schema generation listener for schema events.
|
void |
setForeignKeys(boolean fks)
Set whether foreign keys should be generated.
|
void |
setIndexes(boolean indexes)
Set whether indexes should be generated.
|
void |
setOpenJPATables(boolean openjpaTables)
Whether to generate info on special tables used by OpenJPA components
for bookkeeping.
|
void |
setPrimaryKeys(boolean pks)
Set whether primary keys should be generated.
|
void |
setSchemaGroup(SchemaGroup group)
Set the schema group to add generated schemas to.
|
void |
setSequences(boolean seqs)
Set whether sequences should be generated.
|
public SchemaGenerator(JDBCConfiguration conf)
conf
- configuration for connecting to the data storepublic boolean getIndexes()
public void setIndexes(boolean indexes)
public boolean getForeignKeys()
public void setForeignKeys(boolean fks)
public boolean getPrimaryKeys()
public void setPrimaryKeys(boolean pks)
public boolean getSequences()
public void setSequences(boolean seqs)
public boolean getOpenJPATables()
public void setOpenJPATables(boolean openjpaTables)
public SchemaGroup getSchemaGroup()
public void setSchemaGroup(SchemaGroup group)
public void generateSchemas() throws SQLException
generateIndexes(java.lang.String, java.lang.String[])
, generatePrimaryKeys(java.lang.String, java.lang.String[])
, and
generateForeignKeys(java.lang.String, java.lang.String[])
automatically.SQLException
@Deprecated public void generateSchemas(String[] schemasAndTables) throws SQLException
SQLException
public void generateSchemas(DBIdentifier[] schemasAndTables) throws SQLException
generateIndexes(java.lang.String, java.lang.String[])
,
generatePrimaryKeys(java.lang.String, java.lang.String[])
, and generateForeignKeys(java.lang.String, java.lang.String[])
automatically.SQLException
@Deprecated public void generateSchema(String name, String[] tableNames) throws SQLException
name
- tableNames
- SQLException
public void generateSchema(DBIdentifier name, DBIdentifier[] tableNames) throws SQLException
Schema
matching the given database
schema to the current group. No foreign keys are generated because
some keys might span schemas. You must call
generatePrimaryKeys(java.lang.String, java.lang.String[])
, generateIndexes(java.lang.String, java.lang.String[])
, and
generateForeignKeys(java.lang.String, java.lang.String[])
separately.name
- the database name of the schema, or null for all schemastableNames
- a list of tables to generate in the schema, or null
to generate all tablesSQLException
@Deprecated public void generatePrimaryKeys(String schemaName, String[] tableNames) throws SQLException
generateSchema(java.lang.String, java.lang.String[])
. It should
only be called after all schemas are generated. The schema name and
tables array can be null to indicate that indexes should be generated
for all schemas and/or tables.SQLException
public void generatePrimaryKeys(DBIdentifier schemaName, DBIdentifier[] tableNames) throws SQLException
generateSchema(java.lang.String, java.lang.String[])
. It should
only be called after all schemas are generated. The schema name and
tables array can be null to indicate that indexes should be generated
for all schemas and/or tables.SQLException
@Deprecated public void generateIndexes(String schemaName, String[] tableNames) throws SQLException
generateSchema(java.lang.String, java.lang.String[])
. It should
only be called after all schemas are generated. The schema name and
tables array can be null to indicate that indexes should be generated
for all schemas and/or tables.SQLException
public void generateIndexes(DBIdentifier schemaName, DBIdentifier[] tableNames) throws SQLException
generateSchema(java.lang.String, java.lang.String[])
. It should
only be called after all schemas are generated. The schema name and
tables array can be null to indicate that indexes should be generated
for all schemas and/or tables.SQLException
@Deprecated public void generateForeignKeys(String schemaName, String[] tableNames) throws SQLException
generateSchema(java.lang.String, java.lang.String[])
. It should
only be called after all schemas are generated. The schema name and
tables array can be null to indicate that indexes should be generated
for all schemas and/or tables.SQLException
public void generateForeignKeys(DBIdentifier schemaName, DBIdentifier[] tableNames) throws SQLException
generateSchema(java.lang.String, java.lang.String[])
. It should
only be called after all schemas are generated. The schema name and
tables array can be null to indicate that indexes should be generated
for all schemas and/or tables.SQLException
@Deprecated public void generateTables(String schemaName, String tableName, Connection conn, DatabaseMetaData meta) throws SQLException
SQLException
public void generateTables(DBIdentifier schemaName, DBIdentifier tableName, Connection conn, DatabaseMetaData meta) throws SQLException
SQLException
@Deprecated public void generatePrimaryKeys(String schemaName, String tableName, Connection conn, DatabaseMetaData meta) throws SQLException
SQLException
public void generatePrimaryKeys(DBIdentifier schemaName, DBIdentifier tableName, Connection conn, DatabaseMetaData meta) throws SQLException
SQLException
@Deprecated public void generateIndexes(String schemaName, String tableName, Connection conn, DatabaseMetaData meta) throws SQLException
SQLException
public void generateIndexes(DBIdentifier schemaName, DBIdentifier tableName, Connection conn, DatabaseMetaData meta) throws SQLException
SQLException
public void generateForeignKeys(String schemaName, String tableName, Connection conn, DatabaseMetaData meta) throws SQLException
SQLException
public void generateForeignKeys(DBIdentifier schemaName, DBIdentifier tableName, Connection conn, DatabaseMetaData meta) throws SQLException
SQLException
@Deprecated public void generateSequences(String schemaName, String sequenceName, Connection conn, DatabaseMetaData meta) throws SQLException
SQLException
public void generateSequences(DBIdentifier schemaName, DBIdentifier sequenceName, Connection conn, DatabaseMetaData meta) throws SQLException
SQLException
public void addListener(SchemaGenerator.Listener l)
l
- the listener to addpublic boolean removeListener(SchemaGenerator.Listener l)
l
- the listener to removeCopyright © 2006–2022 Apache Software Foundation. All rights reserved.