public class MappingTool extends Object implements MetaDataModes
Modifier and Type | Class and Description |
---|---|
static class |
MappingTool.Flags
Run flags.
|
static interface |
MappingTool.ImportExport
Helper used to import and export mapping data.
|
Modifier and Type | Field and Description |
---|---|
static String |
ACTION_ADD |
static String |
ACTION_BUILD_SCHEMA |
static String |
ACTION_DROP |
static String |
ACTION_DROP_SCHEMA |
static String |
ACTION_EXPORT |
static String |
ACTION_IMPORT |
static String |
ACTION_REFRESH |
static String |
ACTION_SCRIPT_CREATE |
static String |
ACTION_SCRIPT_DROP |
static String |
ACTION_SCRIPT_LOAD |
static String |
ACTION_VALIDATE |
static String[] |
ACTIONS |
static String |
SCHEMA_ACTION_NONE |
MODE_ALL, MODE_ANN_MAPPING, MODE_MAPPING, MODE_MAPPING_INIT, MODE_META, MODE_NONE, MODE_QUERY
Constructor and Description |
---|
MappingTool(JDBCConfiguration conf,
String action,
boolean meta)
Constructor.
|
MappingTool(JDBCConfiguration conf,
String action,
boolean meta,
ClassLoader loader)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
Reset the internal repository.
|
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.
|
Writer |
getMappingWriter()
The stream to export the planned mappings to as an XML document.
|
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.
|
boolean |
getRollbackBeforeDDL()
If true, rollback will be performed before each DDL statement is executed.
|
String |
getSchemaAction()
The schema modification policy, or
none . |
SchemaGroup |
getSchemaGroup()
Return the schema group to use in mapping.
|
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(String[] arguments)
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 |
record(MappingTool.Flags flags) |
void |
run(Class<?> cls)
Run the configured action on the given instance.
|
static boolean |
run(JDBCConfiguration conf,
String[] args,
MappingTool.Flags flags,
ClassLoader loader)
Run the tool.
|
static boolean |
run(JDBCConfiguration conf,
String[] args,
Options opts,
ClassLoader loader)
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(Writer mappingWriter)
The stream to export the planned mappings to as an XML document.
|
void |
setMetaDataFile(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 |
setRollbackBeforeDDL(boolean rollbackBeforeDDL)
If true, rollback will be performed before each DDL statement is executed.
|
void |
setSchemaAction(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(Writer schemaWriter)
The stream to export the planned schema to as an XML document.
|
void |
setSequences(boolean seqs)
Whether to manipulate sequences.
|
public static final String SCHEMA_ACTION_NONE
public static final String ACTION_ADD
public static final String ACTION_REFRESH
public static final String ACTION_BUILD_SCHEMA
public static final String ACTION_DROP
public static final String ACTION_DROP_SCHEMA
public static final String ACTION_VALIDATE
public static final String ACTION_EXPORT
public static final String ACTION_IMPORT
public static final String ACTION_SCRIPT_CREATE
public static final String ACTION_SCRIPT_DROP
public static final String ACTION_SCRIPT_LOAD
public static final String[] ACTIONS
public MappingTool(JDBCConfiguration conf, String action, boolean meta)
public MappingTool(JDBCConfiguration conf, String action, boolean meta, ClassLoader loader)
public String getAction()
public boolean isMetaDataAction()
public String getSchemaAction()
none
. See the
ACTION constants in SchemaTool
. May be a comma-separated
list of values. Defaults to SchemaTool.ACTION_ADD
.public void setSchemaAction(String schemaAction)
none
. See the
ACTION constants in SchemaTool
. May be a comma-separated
list of values. 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 boolean getRollbackBeforeDDL()
public void setRollbackBeforeDDL(boolean rollbackBeforeDDL)
public void setSchemaTool(SchemaTool tool)
public Writer getSchemaWriter()
public void setSchemaWriter(Writer schemaWriter)
public Writer getMappingWriter()
public void setMappingWriter(Writer mappingWriter)
public File getMetaDataFile()
public void setMetaDataFile(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 record(MappingTool.Flags flags)
public void run(Class<?> cls)
public static void main(String[] arguments) throws IOException, 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
.-sqlFile
flag to write the SQL script
in a different Java character set encoding than the default JVM locale,
such as UTF-8
.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
IOException
SQLException
public static boolean run(JDBCConfiguration conf, String[] args, Options opts, ClassLoader loader) throws IOException, SQLException
IOException
SQLException
main(java.lang.String[])
public static boolean run(JDBCConfiguration conf, String[] args, MappingTool.Flags flags, ClassLoader loader) throws IOException, SQLException
IOException
SQLException
Copyright © 2006–2022 Apache Software Foundation. All rights reserved.