Package org.hibernate.tool.hbm2ddl
Class SchemaExport
- java.lang.Object
-
- org.hibernate.tool.hbm2ddl.SchemaExport
-
public class SchemaExport extends java.lang.ObjectCommand-line tool for exporting (create and/or drop) a database schema. The export can be sent directly to the database, written to script or both.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSchemaExport.Actionstatic classSchemaExport.Type
-
Constructor Summary
Constructors Constructor Description SchemaExport()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static MetadataImplementorbuildMetadataFromMainArgs(java.lang.String[] args)Intended for test usage only.static TargetDescriptorbuildTargetDescriptor(java.util.EnumSet<TargetType> targetTypes, java.lang.String outputFile, ServiceRegistry serviceRegistry)voidcreate(java.util.EnumSet<TargetType> targetTypes, Metadata metadata)voidcreateOnly(java.util.EnumSet<TargetType> targetTypes, Metadata metadata)voiddoExecution(SchemaExport.Action action, boolean needsJdbc, Metadata metadata, ServiceRegistry serviceRegistry, TargetDescriptor targetDescriptor)voiddrop(java.util.EnumSet<TargetType> targetTypes, Metadata metadata)voidexecute(java.util.EnumSet<TargetType> targetTypes, SchemaExport.Action action, Metadata metadata)voidexecute(java.util.EnumSet<TargetType> targetTypes, SchemaExport.Action action, Metadata metadata, ServiceRegistry serviceRegistry)static voidexecute(org.hibernate.tool.hbm2ddl.SchemaExport.CommandLineArgs commandLineArgs)java.util.ListgetExceptions()Returns a List of all Exceptions which occurred during the export.static voidmain(java.lang.String[] args)voidperform(SchemaExport.Action action, Metadata metadata, ScriptTargetOutput target)For testing useSchemaExportsetDelimiter(java.lang.String delimiter)Set the end of statement delimiterSchemaExportsetFormat(boolean format)Should we format the sql strings?SchemaExportsetHaltOnError(boolean haltOnError)Should we stop once an error occurs?SchemaExportsetImportFiles(java.lang.String importFiles)Comma-separated list of resource names to use for database init commands on create.SchemaExportsetManageNamespaces(boolean manageNamespaces)SchemaExportsetOutputFile(java.lang.String filename)For generating a export script file, this is the file which will be written.
-
-
-
Method Detail
-
setOutputFile
public SchemaExport setOutputFile(java.lang.String filename)
For generating a export script file, this is the file which will be written.- Parameters:
filename- The name of the file to which to write the export script.- Returns:
- this
-
setImportFiles
public SchemaExport setImportFiles(java.lang.String importFiles)
Comma-separated list of resource names to use for database init commands on create.- Parameters:
importFiles- The comma-separated list of init file resources names- Returns:
- this
-
setDelimiter
public SchemaExport setDelimiter(java.lang.String delimiter)
Set the end of statement delimiter- Parameters:
delimiter- The delimiter- Returns:
- this
-
setFormat
public SchemaExport setFormat(boolean format)
Should we format the sql strings?- Parameters:
format- Should we format SQL strings- Returns:
- this
-
setHaltOnError
public SchemaExport setHaltOnError(boolean haltOnError)
Should we stop once an error occurs?- Parameters:
haltOnError- True if export should stop after error.- Returns:
- this
-
setManageNamespaces
public SchemaExport setManageNamespaces(boolean manageNamespaces)
-
drop
public void drop(java.util.EnumSet<TargetType> targetTypes, Metadata metadata)
-
create
public void create(java.util.EnumSet<TargetType> targetTypes, Metadata metadata)
-
createOnly
public void createOnly(java.util.EnumSet<TargetType> targetTypes, Metadata metadata)
-
execute
public void execute(java.util.EnumSet<TargetType> targetTypes, SchemaExport.Action action, Metadata metadata)
-
execute
public void execute(java.util.EnumSet<TargetType> targetTypes, SchemaExport.Action action, Metadata metadata, ServiceRegistry serviceRegistry)
-
doExecution
public void doExecution(SchemaExport.Action action, boolean needsJdbc, Metadata metadata, ServiceRegistry serviceRegistry, TargetDescriptor targetDescriptor)
-
buildTargetDescriptor
public static TargetDescriptor buildTargetDescriptor(java.util.EnumSet<TargetType> targetTypes, java.lang.String outputFile, ServiceRegistry serviceRegistry)
-
perform
public void perform(SchemaExport.Action action, Metadata metadata, ScriptTargetOutput target)
For testing use
-
main
public static void main(java.lang.String[] args)
-
execute
public static void execute(org.hibernate.tool.hbm2ddl.SchemaExport.CommandLineArgs commandLineArgs) throws java.lang.Exception- Throws:
java.lang.Exception
-
buildMetadataFromMainArgs
public static MetadataImplementor buildMetadataFromMainArgs(java.lang.String[] args) throws java.lang.Exception
Intended for test usage only. Builds a Metadata using the same algorithm asmain(java.lang.String[])- Parameters:
args- The "command line args"- Returns:
- The built Metadata
- Throws:
java.lang.Exception- Problems building the Metadata
-
getExceptions
public java.util.List getExceptions()
Returns a List of all Exceptions which occurred during the export.- Returns:
- A List containing the Exceptions occurred during the export
-
-