|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.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 java.lang.String |
ACTION_ADD
|
static java.lang.String |
ACTION_BUILD
|
static java.lang.String |
ACTION_CREATEDB
|
static java.lang.String |
ACTION_DROP
|
static java.lang.String |
ACTION_DROPDB
|
static java.lang.String |
ACTION_EXPORT
|
static java.lang.String |
ACTION_IMPORT
|
static java.lang.String |
ACTION_REFLECT
|
static java.lang.String |
ACTION_REFRESH
|
static java.lang.String |
ACTION_RETAIN
|
static java.lang.String[] |
ACTIONS
|
Constructor Summary | |
---|---|
SchemaTool(JDBCConfiguration conf)
Default constructor. |
|
SchemaTool(JDBCConfiguration conf,
java.lang.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. |
java.lang.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. |
java.io.Writer |
getWriter()
The stream to write to for the creation of SQL scripts. |
static void |
main(java.lang.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,
java.lang.String[] args,
org.apache.openjpa.lib.util.Options opts)
Run the tool. |
static boolean |
run(JDBCConfiguration conf,
java.lang.String[] args,
SchemaTool.Flags flags,
java.lang.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(java.io.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 java.lang.String ACTION_ADD
public static final java.lang.String ACTION_DROP
public static final java.lang.String ACTION_RETAIN
public static final java.lang.String ACTION_REFRESH
public static final java.lang.String ACTION_BUILD
public static final java.lang.String ACTION_REFLECT
public static final java.lang.String ACTION_CREATEDB
public static final java.lang.String ACTION_DROPDB
public static final java.lang.String ACTION_IMPORT
public static final java.lang.String ACTION_EXPORT
public static final java.lang.String[] ACTIONS
Constructor Detail |
---|
public SchemaTool(JDBCConfiguration conf)
run()
method will be a no-op.
public SchemaTool(JDBCConfiguration conf, java.lang.String action)
Method Detail |
---|
public java.lang.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 java.io.Writer getWriter()
public void setWriter(java.io.Writer writer)
public SchemaGroup getSchemaGroup()
public void setSchemaGroup(SchemaGroup group)
public void run() throws java.sql.SQLException
java.sql.SQLException
public void record()
SchemaFactory
.
public boolean createTable(Table table) throws java.sql.SQLException
java.sql.SQLException
public boolean dropTable(Table table) throws java.sql.SQLException
java.sql.SQLException
public boolean createSequence(Sequence seq) throws java.sql.SQLException
java.sql.SQLException
public boolean dropSequence(Sequence seq) throws java.sql.SQLException
java.sql.SQLException
public boolean createIndex(Index idx, Table table) throws java.sql.SQLException
java.sql.SQLException
public boolean dropIndex(Index idx) throws java.sql.SQLException
java.sql.SQLException
public boolean addColumn(Column col) throws java.sql.SQLException
java.sql.SQLException
public boolean dropColumn(Column col) throws java.sql.SQLException
java.sql.SQLException
public boolean addPrimaryKey(PrimaryKey pk) throws java.sql.SQLException
java.sql.SQLException
public boolean dropPrimaryKey(PrimaryKey pk) throws java.sql.SQLException
java.sql.SQLException
public boolean addForeignKey(ForeignKey fk) throws java.sql.SQLException
java.sql.SQLException
public boolean dropForeignKey(ForeignKey fk) throws java.sql.SQLException
java.sql.SQLException
public SchemaGroup getDBSchemaGroup()
public void setDBSchemaGroup(SchemaGroup db)
public static void main(java.lang.String[] args) throws java.io.IOException, java.sql.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 myschema.xml
java.io.IOException
java.sql.SQLException
public static boolean run(JDBCConfiguration conf, java.lang.String[] args, org.apache.openjpa.lib.util.Options opts) throws java.io.IOException, java.sql.SQLException
java.io.IOException
java.sql.SQLException
main(java.lang.String[])
public static boolean run(JDBCConfiguration conf, java.lang.String[] args, SchemaTool.Flags flags, java.lang.ClassLoader loader) throws java.io.IOException, java.sql.SQLException
java.io.IOException
java.sql.SQLException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |