|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.openjpa.jdbc.meta.MappingTool
public class MappingTool
Tool for manipulating class mappings and associated schema.
Nested Class Summary | |
---|---|
static class |
MappingTool.Flags
Run flags. |
static interface |
MappingTool.ImportExport
Helper used to import and export mapping data. |
Field Summary | |
---|---|
static java.lang.String |
ACTION_ADD
|
static java.lang.String |
ACTION_BUILD_SCHEMA
|
static java.lang.String |
ACTION_DROP
|
static java.lang.String |
ACTION_EXPORT
|
static java.lang.String |
ACTION_IMPORT
|
static java.lang.String |
ACTION_REFRESH
|
static java.lang.String |
ACTION_VALIDATE
|
static java.lang.String[] |
ACTIONS
|
static java.lang.String |
SCHEMA_ACTION_NONE
|
Fields inherited from interface org.apache.openjpa.meta.MetaDataModes |
---|
MODE_MAPPING, MODE_MAPPING_INIT, MODE_META, MODE_NONE, MODE_QUERY |
Constructor Summary | |
---|---|
MappingTool(JDBCConfiguration conf,
java.lang.String action,
boolean meta)
Constructor. |
Method Summary | |
---|---|
void |
clear()
Reset the internal repository. |
java.lang.String |
getAction()
The action supplied on construction. |
boolean |
getDropUnusedComponents()
Whether schema components that are unused by any mapping will be dropped from this tool's SchemaGroup , and, depending on
the schema action, from the database. |
boolean |
getForeignKeys()
Whether foreign keys on existing tables should be manipulated. |
boolean |
getIgnoreErrors()
Whether and SQL errors should cause a failure or just issue a warning. |
boolean |
getIndexes()
Whether indexes on existing tables should be manipulated. |
java.io.Writer |
getMappingWriter()
The stream to export the planned mappings to as an XML document. |
java.io.File |
getMetaDataFile()
If adding metadata, the metadata file to add to. |
boolean |
getPrimaryKeys()
Whether primary keys on existing tables should be manipulated. |
boolean |
getReadSchema()
Set to true to read the entire schema before mapping. |
MappingRepository |
getRepository()
Return the repository to use to access mapping information. |
java.lang.String |
getSchemaAction()
The schema modification policy, or none . |
SchemaGroup |
getSchemaGroup()
Return the schema group to use in mapping. |
SchemaTool |
getSchemaTool()
Return the schema tool to use for schema modification. |
java.io.Writer |
getSchemaWriter()
The stream to export the planned schema to as an XML document. |
boolean |
getSequences()
Whether to manipulate sequences. |
boolean |
isMetaDataAction()
Whether the action works on metadata as well as mappings. |
static void |
main(java.lang.String[] args)
Usage: java org.apache.openjpa.jdbc.meta.MappingTool [option]* [-action/-a <refresh | add | buildSchema | drop | validate | import | export>] <class name | .java file | .class file | .jdo file>* Where the following options are recognized. |
void |
record()
Records the changes that have been made to both the mappings and the associated schema, and clears the tool for further use. |
void |
run(java.lang.Class cls)
Run the configured action on the given instance. |
static boolean |
run(JDBCConfiguration conf,
java.lang.String[] args,
MappingTool.Flags flags,
java.lang.ClassLoader loader)
Run the tool. |
static boolean |
run(JDBCConfiguration conf,
java.lang.String[] args,
org.apache.openjpa.lib.util.Options opts)
Run the tool. |
void |
setDropUnusedComponents(boolean dropUnused)
Whether schema components that are unused by any mapping will be dropped from this tool's SchemaGroup , and, depending on
the schema action, from the database. |
void |
setForeignKeys(boolean fks)
Whether foreign keys on existing tables should be manipulated. |
void |
setIgnoreErrors(boolean ignoreErrors)
Whether and SQL errors should cause a failure or just issue a warning. |
void |
setIndexes(boolean indexes)
Whether indexes on existing tables should be manipulated. |
void |
setMappingWriter(java.io.Writer mappingWriter)
The stream to export the planned mappings to as an XML document. |
void |
setMetaDataFile(java.io.File file)
If adding metadata, the metadata file to add to. |
void |
setPrimaryKeys(boolean pks)
Whether primary keys on existing tables should be manipulated. |
void |
setReadSchema(boolean readSchema)
Set to true to read the entire schema before mapping. |
void |
setRepository(MappingRepository repos)
Set the repository to use to access mapping information. |
void |
setSchemaAction(java.lang.String schemaAction)
The schema modification policy, or none . |
void |
setSchemaGroup(SchemaGroup schema)
Set the schema to use in mapping. |
void |
setSchemaTool(SchemaTool tool)
Set the schema tool to use for schema modification. |
void |
setSchemaWriter(java.io.Writer schemaWriter)
The stream to export the planned schema to as an XML document. |
void |
setSequences(boolean seqs)
Whether to manipulate sequences. |
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 SCHEMA_ACTION_NONE
public static final java.lang.String ACTION_ADD
public static final java.lang.String ACTION_REFRESH
public static final java.lang.String ACTION_BUILD_SCHEMA
public static final java.lang.String ACTION_DROP
public static final java.lang.String ACTION_VALIDATE
public static final java.lang.String ACTION_EXPORT
public static final java.lang.String ACTION_IMPORT
public static final java.lang.String[] ACTIONS
Constructor Detail |
---|
public MappingTool(JDBCConfiguration conf, java.lang.String action, boolean meta)
Method Detail |
---|
public java.lang.String getAction()
public boolean isMetaDataAction()
public java.lang.String getSchemaAction()
none
. See the
ACTION constants in SchemaTool
. Defaults to
SchemaTool.ACTION_ADD
.
public void setSchemaAction(java.lang.String schemaAction)
none
. See the
ACTION constants in SchemaTool
. Defaults to
SchemaTool.ACTION_ADD
.
public boolean getReadSchema()
public void setReadSchema(boolean readSchema)
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 boolean getDropUnusedComponents()
SchemaGroup
, and, depending on
the schema action, from the database. Defaults to true.
public void setDropUnusedComponents(boolean dropUnused)
SchemaGroup
, and, depending on
the schema action, from the database. Defaults to true.
public void setIgnoreErrors(boolean ignoreErrors)
public boolean getIgnoreErrors()
public SchemaTool getSchemaTool()
public void setSchemaTool(SchemaTool tool)
public java.io.Writer getSchemaWriter()
public void setSchemaWriter(java.io.Writer schemaWriter)
public java.io.Writer getMappingWriter()
public void setMappingWriter(java.io.Writer mappingWriter)
public java.io.File getMetaDataFile()
public void setMetaDataFile(java.io.File file)
public MappingRepository getRepository()
MappingRepository
.
public void setRepository(MappingRepository repos)
public SchemaGroup getSchemaGroup()
public void setSchemaGroup(SchemaGroup schema)
public void clear()
record()
.
public void record()
public void run(java.lang.Class cls)
public static void main(java.lang.String[] args) throws java.io.IOException, java.sql.SQLException
OpenJPAConfiguration
. Optional.JDBCConfiguration
can be set by
using their names and supplying a value. For example:
-licenseKey adslfja83r3lkadf
add
action with
the -meta true
flag, or the file to dump to if using
the export
action.SchemaTool
defines the actions possible. The actions will
apply to all schema components used by the mappings involved.
Unless you are running the mapping tool on all of your persistent
types at once, be careful running schema actions that can drop data.
It is possible to accidentally drop schema components that are
used by classes you aren't currently running the tool over. The
action defaults to add
.SchemaTool
.SchemaTool
.SchemaTool
.SchemaTool
.SchemaGenerator
. This option
is ignored if readSchema
is false.-meta
option, adds new
default metadata for the given class(es). Otherwise, brings the
mapping information up-to-date with the class
definitions. OpenJPA will attempt to use any provided mapping
information, and fill in missing information. OpenJPA will fail if
the provided information conflicts with the class definition.-meta
option, also deletes metadata.file
option.-meta
option, the metadata will be
included in the export.
java org.apache.openjpa.jdbc.meta.MappingTool mypackage.jdo
java org.apache.openjpa.jdbc.meta.MappingTool -sa refresh
-dt true
java org.apache.openjpa.jbdc.meta.MappingTool
-a validate Person.java
java org.apache.openjpa.jbdc.meta.MappingTool
-a drop Person.java
java org.apache.openjpa.jdbc.meta.MappingTool
-f mypackage.orm -a export mypackage.jdo
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, MappingTool.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 |