Package org.hibernate.tool.hbm2ddl
Class SchemaExport
java.lang.Object
org.hibernate.tool.hbm2ddl.SchemaExport
Command-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 -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic org.hibernate.boot.spi.MetadataImplementorbuildMetadataFromMainArgs(String[] args) Intended for test usage only.static org.hibernate.tool.schema.spi.TargetDescriptorbuildTargetDescriptor(EnumSet<org.hibernate.tool.schema.TargetType> targetTypes, String outputFile, boolean append, org.hibernate.service.ServiceRegistry serviceRegistry) static org.hibernate.tool.schema.spi.TargetDescriptorbuildTargetDescriptor(EnumSet<org.hibernate.tool.schema.TargetType> targetTypes, String outputFile, org.hibernate.service.ServiceRegistry serviceRegistry) voidcreate(EnumSet<org.hibernate.tool.schema.TargetType> targetTypes, org.hibernate.boot.Metadata metadata) voidcreateOnly(EnumSet<org.hibernate.tool.schema.TargetType> targetTypes, org.hibernate.boot.Metadata metadata) voiddoExecution(SchemaExport.Action action, boolean needsJdbc, org.hibernate.boot.Metadata metadata, org.hibernate.service.ServiceRegistry serviceRegistry, org.hibernate.tool.schema.spi.TargetDescriptor targetDescriptor) voiddrop(EnumSet<org.hibernate.tool.schema.TargetType> targetTypes, org.hibernate.boot.Metadata metadata) voidexecute(EnumSet<org.hibernate.tool.schema.TargetType> targetTypes, SchemaExport.Action action, org.hibernate.boot.Metadata metadata) voidexecute(EnumSet<org.hibernate.tool.schema.TargetType> targetTypes, SchemaExport.Action action, org.hibernate.boot.Metadata metadata, org.hibernate.service.ServiceRegistry serviceRegistry) static voidexecute(org.hibernate.tool.hbm2ddl.SchemaExport.CommandLineArgs commandLineArgs) Returns a List of all Exceptions which occurred during the export.static voidvoidperform(SchemaExport.Action action, org.hibernate.boot.Metadata metadata, org.hibernate.tool.schema.spi.ScriptTargetOutput target) For testing usesetDelimiter(String delimiter) Set the end of statement delimitersetFormat(boolean format) Should we format the sql strings?setHaltOnError(boolean haltOnError) Should we stop once an error occurs?setImportFiles(String importFiles) Comma-separated list of resource names to use for database init commands on create.setManageNamespaces(boolean manageNamespaces) setOutputFile(String filename) For generating a export script file, this is the file which will be written.For generating a export script file, by default the content will be appended at the begin or end of the file.
-
Constructor Details
-
SchemaExport
public SchemaExport()
-
-
Method Details
-
setOutputFile
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
-
setOverrideOutputFileContent
For generating a export script file, by default the content will be appended at the begin or end of the file. The sql will be written at the beginning of the file rather append to the end.- Returns:
- this
-
setImportFiles
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
Set the end of statement delimiter- Parameters:
delimiter- The delimiter- Returns:
- this
-
setFormat
Should we format the sql strings?- Parameters:
format- Should we format SQL strings- Returns:
- this
-
setHaltOnError
Should we stop once an error occurs?- Parameters:
haltOnError- True if export should stop after error.- Returns:
- this
-
setManageNamespaces
-
drop
public void drop(EnumSet<org.hibernate.tool.schema.TargetType> targetTypes, org.hibernate.boot.Metadata metadata) -
create
public void create(EnumSet<org.hibernate.tool.schema.TargetType> targetTypes, org.hibernate.boot.Metadata metadata) -
createOnly
public void createOnly(EnumSet<org.hibernate.tool.schema.TargetType> targetTypes, org.hibernate.boot.Metadata metadata) -
execute
public void execute(EnumSet<org.hibernate.tool.schema.TargetType> targetTypes, SchemaExport.Action action, org.hibernate.boot.Metadata metadata) -
execute
public void execute(EnumSet<org.hibernate.tool.schema.TargetType> targetTypes, SchemaExport.Action action, org.hibernate.boot.Metadata metadata, org.hibernate.service.ServiceRegistry serviceRegistry) -
doExecution
public void doExecution(SchemaExport.Action action, boolean needsJdbc, org.hibernate.boot.Metadata metadata, org.hibernate.service.ServiceRegistry serviceRegistry, org.hibernate.tool.schema.spi.TargetDescriptor targetDescriptor) -
buildTargetDescriptor
-
buildTargetDescriptor
-
perform
public void perform(SchemaExport.Action action, org.hibernate.boot.Metadata metadata, org.hibernate.tool.schema.spi.ScriptTargetOutput target) For testing use -
main
-
execute
public static void execute(org.hibernate.tool.hbm2ddl.SchemaExport.CommandLineArgs commandLineArgs) throws Exception - Throws:
Exception
-
buildMetadataFromMainArgs
public static org.hibernate.boot.spi.MetadataImplementor buildMetadataFromMainArgs(String[] args) throws 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:
Exception- Problems building the Metadata
-
getExceptions
Returns a List of all Exceptions which occurred during the export.- Returns:
- A List containing the Exceptions occurred during the export
-