Package org.datanucleus.store.schema
Class SchemaTool
java.lang.Object
org.datanucleus.store.schema.SchemaTool
SchemaTool providing an interface for the maintenance of schemas.
These utilities include:-
- creation of a schema/catalog in the datastore
- deletion of a schema/catalog in the datastore
- creation of tables representing classes specified in input data
- deletion of tables representing classes specified in input data
- validation of tables representing classes specified in input data
- details about the datastore
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate String
Name of the persistence API to use.private String
Name of the schema (for use with createDatabase, deleteDatabase modes).private boolean
When generating DDL to a file, whether to generate complete DDL, or just for missing components.private String
Name of a file in which to put the DDL (or null if wanting to execute in the datastore).private boolean
When updating the schema, whether to include any auto-start mechanism.static final NucleusLogger
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
private String
Name of the schema (for use with createDatabase, deleteDatabase modes).private boolean
Whether to operate in verbose mode. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
createDatabase
(SchemaAwareStoreManager storeMgr, String catalogName, String schemaName) void
createSchemaForClasses
(SchemaAwareStoreManager storeMgr, Set<String> classNames) void
deleteDatabase
(SchemaAwareStoreManager storeMgr, String catalogName, String schemaName) void
deleteSchemaForClasses
(SchemaAwareStoreManager storeMgr, Set<String> classNames) getApi()
Accessor for the metadata API (JDO, JPA) in use (metadata definition)boolean
boolean
static PersistenceNucleusContext
getNucleusContextForMode
(SchemaTool.Mode mode, String api, Map userProps, String persistenceUnitName, String ddlFile, boolean verbose) Method to create a NucleusContext for the specified mode of SchemaToolstatic PersistenceNucleusContext
getNucleusContextForMode
(SchemaTool.Mode mode, String api, Map userProps, String persistenceUnitName, String ddlFile, boolean verbose, boolean ignoreMetaDataForMissingClasses) Method to create a NucleusContext for the specified mode of SchemaToolMethod to generate the properties to be used by SchemaTool.boolean
static void
Entry method when invoked from the command line.Mutator for the metadata API (JDO, JPA)setCatalogName
(String catalogName) setCompleteDdl
(boolean completeDdl) setDdlFile
(String file) setIncludeAutoStart
(boolean include) setSchemaName
(String schemaName) setVerbose
(boolean verbose) void
validateSchemaForClasses
(SchemaAwareStoreManager storeMgr, Set<String> classNames)
-
Field Details
-
LOGGER
-
OPTION_CREATE_DATABASE
- See Also:
-
OPTION_DELETE_DATABASE
- See Also:
-
OPTION_CREATE_TABLES_FOR_CLASSES
- See Also:
-
OPTION_DELETE_TABLES_FOR_CLASSES
- See Also:
-
OPTION_DELETE_CREATE_TABLES_FOR_CLASSES
- See Also:
-
OPTION_VALIDATE_TABLES_FOR_CLASSES
- See Also:
-
OPTION_DBINFO
- See Also:
-
OPTION_SCHEMAINFO
- See Also:
-
OPTION_DDL_FILE
- See Also:
-
OPTION_COMPLETE_DDL
- See Also:
-
OPTION_INCLUDE_AUTO_START
- See Also:
-
OPTION_API
- See Also:
-
OPTION_CATALOG_NAME
- See Also:
-
OPTION_SCHEMA_NAME
- See Also:
-
apiName
Name of the persistence API to use. -
schemaName
Name of the schema (for use with createDatabase, deleteDatabase modes). -
catalogName
Name of the schema (for use with createDatabase, deleteDatabase modes). -
ddlFilename
Name of a file in which to put the DDL (or null if wanting to execute in the datastore). -
completeDdl
private boolean completeDdlWhen generating DDL to a file, whether to generate complete DDL, or just for missing components. -
includeAutoStart
private boolean includeAutoStartWhen updating the schema, whether to include any auto-start mechanism. -
verbose
private boolean verboseWhether to operate in verbose mode.
-
-
Constructor Details
-
SchemaTool
public SchemaTool()Constructor
-
-
Method Details
-
main
Entry method when invoked from the command line.- Parameters:
args
- List of options for processing by the available methods in this class.- Throws:
Exception
- If an error occurs in operation
-
getPropertiesForSchemaTool
Method to generate the properties to be used by SchemaTool. This includes whether to create DDL to a file, and whether to include any auto-start mechanism- Returns:
- The properties to use with SchemaTool.
-
createDatabase
-
deleteDatabase
-
createSchemaForClasses
-
deleteSchemaForClasses
-
validateSchemaForClasses
-
getNucleusContextForMode
public static PersistenceNucleusContext getNucleusContextForMode(SchemaTool.Mode mode, String api, Map userProps, String persistenceUnitName, String ddlFile, boolean verbose) Method to create a NucleusContext for the specified mode of SchemaTool- Parameters:
mode
- Mode of operation of SchemaToolapi
- Persistence APIuserProps
- Map containing user provided properties (usually input via a file)persistenceUnitName
- Name of the persistence-unit (if any)ddlFile
- Name of a file to output DDL toverbose
- Verbose mode- Returns:
- The NucleusContext to use
- Throws:
NucleusException
- Thrown if an error occurs in creating the required NucleusContext
-
getNucleusContextForMode
public static PersistenceNucleusContext getNucleusContextForMode(SchemaTool.Mode mode, String api, Map userProps, String persistenceUnitName, String ddlFile, boolean verbose, boolean ignoreMetaDataForMissingClasses) Method to create a NucleusContext for the specified mode of SchemaTool- Parameters:
mode
- Mode of operation of SchemaToolapi
- Persistence APIuserProps
- Map containing user provided properties (usually input via a file)persistenceUnitName
- Name of the persistence-unit (if any)ddlFile
- Name of a file to output DDL toverbose
- Verbose modeignoreMetaDataForMissingClasses
- Whether to ignore metadata for missing classes- Returns:
- The NucleusContext to use
- Throws:
NucleusException
- Thrown if an error occurs in creating the required NucleusContext
-
getApi
Accessor for the metadata API (JDO, JPA) in use (metadata definition)- Returns:
- the API
-
setApi
Mutator for the metadata API (JDO, JPA)- Parameters:
api
- the API- Returns:
- The SchemaTool instance
-
isVerbose
public boolean isVerbose()- Returns:
- the verbose
-
setVerbose
- Parameters:
verbose
- the verbose to set- Returns:
- The SchemaTool instance
-
getSchemaName
-
setSchemaName
-
getCatalogName
-
setCatalogName
-
getDdlFile
-
setDdlFile
-
setCompleteDdl
-
getCompleteDdl
public boolean getCompleteDdl() -
setIncludeAutoStart
-
getIncludeAutoStart
public boolean getIncludeAutoStart()
-