|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.openjpa.jdbc.schema.SchemaTool
public class SchemaTool
The SchemaTool is used to manage the database schema. Note that the
tool never adds or drops unique constraints from existing tables, because
JDBC DatabaseMetaData
does not include information on these
constraints.
Nested Class Summary | |
---|---|
static class |
SchemaTool.Flags
Run flags. |
Field Summary | |
---|---|
static String |
ACTION_ADD
|
static String |
ACTION_BUILD
|
static String |
ACTION_CREATEDB
|
static String |
ACTION_DELETE_TABLE_CONTENTS
|
static String |
ACTION_DROP
|
static String |
ACTION_DROPDB
|
static String |
ACTION_EXPORT
|
static String |
ACTION_IMPORT
|
static String |
ACTION_REFLECT
|
static String |
ACTION_REFRESH
|
static String |
ACTION_RETAIN
|
static String[] |
ACTIONS
|
Constructor Summary | |
---|---|
SchemaTool(JDBCConfiguration conf)
Default constructor. |
|
SchemaTool(JDBCConfiguration conf,
String action)
Construct a tool to perform the given action. |
Method Summary | |
---|---|
boolean |
addColumn(Column col)
Add the given column to the database schema. |
boolean |
addForeignKey(ForeignKey fk)
Add the given foreign key to the database schema. |
boolean |
addPrimaryKey(PrimaryKey pk)
Add the given primary key to the database schema. |
boolean |
createIndex(Index idx,
Table table)
Add the given index to the database schema. |
boolean |
createSequence(Sequence seq)
Add the given sequence to the database schema. |
boolean |
createTable(Table table)
Add the given table to the database schema. |
boolean |
dropColumn(Column col)
Drop the given column from the database schema. |
boolean |
dropForeignKey(ForeignKey fk)
Drop the given foreign key from the database schema. |
boolean |
dropIndex(Index idx)
Drop the given index from the database schema. |
boolean |
dropPrimaryKey(PrimaryKey pk)
Drop the given primary key from the database schema. |
boolean |
dropSequence(Sequence seq)
Drop the given sequence from the database schema. |
boolean |
dropTable(Table table)
Drop the given table from the database schema. |
String |
getAction()
The action supplied on construction. |
SchemaGroup |
getDBSchemaGroup()
Return the database schema. |
boolean |
getDropSequences()
If true, sequences that appear to be unused will be dropped. |
boolean |
getDropTables()
If true, tables that appear to be unused will be dropped. |
boolean |
getForeignKeys()
Whether foreign keys on existing tables should be manipulated. |
boolean |
getIgnoreErrors()
If true, SQLExceptions thrown during schema manipulation will be printed but ignored. |
boolean |
getIndexes()
Whether indexes on existing tables should be manipulated. |
boolean |
getOpenJPATables()
Whether to act on special tables used by OpenJPA components for bookkeeping. |
boolean |
getPrimaryKeys()
Whether primary keys on existing tables should be manipulated. |
SchemaGroup |
getSchemaGroup()
Return the schema group the tool will act on. |
boolean |
getSequences()
Whether sequences should be manipulated. |
Writer |
getWriter()
The stream to write to for the creation of SQL scripts. |
static void |
main(String[] args)
Usage: java org.apache.openjpa.jdbc.schema.SchemaTool [option]* [-action/-a <add | retain | drop | refresh | createDB | dropDB | build | reflect | import | export>] <.schema file or resource>* Where the following options are recognized. |
void |
record()
Record the changes made to the DB in the current SchemaFactory . |
void |
run()
Run the tool action. |
static boolean |
run(JDBCConfiguration conf,
String[] args,
Options opts)
Run the tool. |
static boolean |
run(JDBCConfiguration conf,
String[] args,
SchemaTool.Flags flags,
ClassLoader loader)
Run the tool. |
void |
setDBSchemaGroup(SchemaGroup db)
Set the database schema. |
void |
setDropSequences(boolean dropSeqs)
If true, sequences that appear to be unused will be dropped. |
void |
setDropTables(boolean dropTables)
If true, tables that appear to be unused will be dropped. |
void |
setForeignKeys(boolean fks)
Whether foreign keys on existing tables should be manipulated. |
void |
setIgnoreErrors(boolean ignoreErrs)
If true, SQLExceptions thrown during schema manipulation will be printed but ignored. |
void |
setIndexes(boolean indexes)
Whether indexes on existing tables should be manipulated. |
void |
setOpenJPATables(boolean openjpaTables)
Whether to act on special tables used by OpenJPA components for bookkeeping. |
void |
setPrimaryKeys(boolean pks)
Whether primary keys on existing tables should be manipulated. |
void |
setSchemaGroup(SchemaGroup group)
Set the schema group the tool will act on. |
void |
setSequences(boolean seqs)
Whether sequences should be manipulated. |
void |
setWriter(Writer writer)
The stream to write to for the creation of SQL scripts. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String ACTION_ADD
public static final String ACTION_DROP
public static final String ACTION_RETAIN
public static final String ACTION_REFRESH
public static final String ACTION_BUILD
public static final String ACTION_REFLECT
public static final String ACTION_CREATEDB
public static final String ACTION_DROPDB
public static final String ACTION_IMPORT
public static final String ACTION_EXPORT
public static final String ACTION_DELETE_TABLE_CONTENTS
public static final String[] ACTIONS
Constructor Detail |
---|
public SchemaTool(JDBCConfiguration conf)
run()
method will be a no-op.
public SchemaTool(JDBCConfiguration conf, String action)
Method Detail |
---|
public String getAction()
public boolean getIgnoreErrors()
public void setIgnoreErrors(boolean ignoreErrs)
public boolean getOpenJPATables()
public void setOpenJPATables(boolean openjpaTables)
public boolean getDropTables()
public void setDropTables(boolean dropTables)
public boolean getDropSequences()
public void setDropSequences(boolean dropSeqs)
public boolean getSequences()
public void setSequences(boolean seqs)
public boolean getIndexes()
public void setIndexes(boolean indexes)
public boolean getForeignKeys()
public void setForeignKeys(boolean fks)
public boolean getPrimaryKeys()
public void setPrimaryKeys(boolean pks)
public Writer getWriter()
public void setWriter(Writer writer)
public SchemaGroup getSchemaGroup()
public void setSchemaGroup(SchemaGroup group)
public void run() throws SQLException
SQLException
public void record()
SchemaFactory
.
public boolean createTable(Table table) throws SQLException
SQLException
public boolean dropTable(Table table) throws SQLException
SQLException
public boolean createSequence(Sequence seq) throws SQLException
SQLException
public boolean dropSequence(Sequence seq) throws SQLException
SQLException
public boolean createIndex(Index idx, Table table) throws SQLException
SQLException
public boolean dropIndex(Index idx) throws SQLException
SQLException
public boolean addColumn(Column col) throws SQLException
SQLException
public boolean dropColumn(Column col) throws SQLException
SQLException
public boolean addPrimaryKey(PrimaryKey pk) throws SQLException
SQLException
public boolean dropPrimaryKey(PrimaryKey pk) throws SQLException
SQLException
public boolean addForeignKey(ForeignKey fk) throws SQLException
SQLException
public boolean dropForeignKey(ForeignKey fk) throws SQLException
SQLException
public SchemaGroup getDBSchemaGroup()
public void setDBSchemaGroup(SchemaGroup db)
public static void main(String[] args) throws IOException, SQLException
JDBCConfiguration
. Optional.JDBCConfiguration
can be set by
using their names and supplying a value. For example:
-licenseKey adslfja83r3lkadf
false
.export
and reflect
actions.reflect
action, whether to reflect on tables with
the name OPENJPA_*
. Under other actions, whether to
drop such tables. Defaults to false
.retain
and refresh
actions. Defaults to
true
.retain
and refresh
actions. Defaults to
true
.false
to prevent writing the schema changes to the
current SchemaFactory
.file
option.file
option.file
option, or to stdout if no file is given.dropTables
.SchemaFactory
.SchemaFactory
's recorded
schema to an XML schema definition file.java org.apache.openjpa.jdbc.schema.SchemaTool -f stdout
-a createDB
java org.apache.openjpa.jdbc.schema.SchemaTool
-a dropDB
java org.apache.openjpa.jdbc.schema.SchemaTool
-a refresh,deleteTableContents
java org.apache.openjpa.jdbc.schema.SchemaTool
myschema.xml
IOException
SQLException
public static boolean run(JDBCConfiguration conf, String[] args, Options opts) throws IOException, SQLException
IOException
SQLException
main(java.lang.String[])
public static boolean run(JDBCConfiguration conf, String[] args, SchemaTool.Flags flags, ClassLoader loader) throws IOException, SQLException
IOException
SQLException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
This documentation is deprecated and will be removed in the next release of WebLogic Server.