Top Description Inners Fields Constructors Methods
org.hibernate.tool.hbm2ddl

public Class SchemaExport

extends Object
Class Inheritance
Imports
java.io.File, .FileInputStream, java.util.ArrayList, .EnumSet, .HashMap, .List, .Map, .Properties, org.hibernate.boot.Metadata, .MetadataBuilder, .MetadataSources, org.hibernate.boot.model.naming.ImplicitNamingStrategy, .PhysicalNamingStrategy, org.hibernate.boot.registry.BootstrapServiceRegistry, .BootstrapServiceRegistryBuilder, .StandardServiceRegistry, .StandardServiceRegistryBuilder, org.hibernate.boot.registry.classloading.spi.ClassLoaderService, org.hibernate.boot.registry.selector.spi.StrategySelector, org.hibernate.boot.spi.MetadataImplementor, org.hibernate.cfg.AvailableSettings, org.hibernate.engine.config.spi.ConfigurationService, org.hibernate.internal.CoreLogging, .CoreMessageLogger, org.hibernate.internal.log.DeprecationLogger, org.hibernate.service.ServiceRegistry, org.hibernate.tool.schema.SourceType, .TargetType, org.hibernate.tool.schema.internal.ExceptionHandlerCollectingImpl, .ExceptionHandlerHaltImpl, .Helper, .SchemaCreatorImpl, org.hibernate.tool.schema.spi.ExceptionHandler, .ExecutionOptions, .SchemaManagementException, .SchemaManagementTool, .SchemaManagementToolCoordinator, .ScriptSourceInput, .ScriptTargetOutput, .SourceDescriptor, .TargetDescriptor

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.
Authors
Daniel Bradby, Gavin King, Steve Ebersole

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum
private static class
private static class
public static enum

Field Summary

Modifier and TypeField and Description
pack-priv boolean
pack-priv String
private final List<Exception>
pack-priv boolean
pack-priv boolean
private String
private static final CoreMessageLogger
pack-priv boolean
pack-priv String

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private static MetadataImplementor
public static MetadataImplementor

Returns:

The built Metadata
buildMetadataFromMainArgs
(String[]
The "command line args"
args
)

Intended for test usage only.

private static StandardServiceRegistry
public static TargetDescriptor
buildTargetDescriptor(EnumSet<TargetType> targetTypes, String outputFile, ServiceRegistry serviceRegistry)

public static TargetDescriptor
buildTargetDescriptor(EnumSet<TargetType> targetTypes, String outputFile, boolean append, ServiceRegistry serviceRegistry)

public void
create(EnumSet<TargetType> targetTypes, Metadata metadata)

public void
createOnly(EnumSet<TargetType> targetTypes, Metadata metadata)

public void
doExecution(SchemaExport.Action action, boolean needsJdbc, Metadata metadata, ServiceRegistry serviceRegistry, TargetDescriptor targetDescriptor)

public void
drop(EnumSet<TargetType> targetTypes, Metadata metadata)

public void
execute(EnumSet<TargetType> targetTypes, SchemaExport.Action action, Metadata metadata)

public void
execute(EnumSet<TargetType> targetTypes, SchemaExport.Action action, Metadata metadata, ServiceRegistry serviceRegistry)

public static void
public List<E>

Returns:

A List containing the Exceptions occurred during the export
getExceptions
()

Returns a List of all Exceptions which occurred during the export.

public static void
main(String[] args)

private boolean
public void
perform(SchemaExport.Action action, Metadata metadata, ScriptTargetOutput target)

For testing use

public SchemaExport

Returns:

this
setDelimiter
(String
The delimiter
delimiter
)

Set the end of statement delimiter

public SchemaExport

Returns:

this
setFormat
(boolean
Should we format SQL strings
format
)

Should we format the sql strings?

public SchemaExport

Returns:

this
setHaltOnError
(boolean
True if export should stop after error.
haltOnError
)

Should we stop once an error occurs?

public SchemaExport

Returns:

this
setImportFiles
(String
The comma-separated list of init file resources names
importFiles
)

Comma-separated list of resource names to use for database init commands on create.

public SchemaExport
setManageNamespaces(boolean manageNamespaces)

public SchemaExport

Returns:

this
setOutputFile
(String
The name of the file to which to write the export script.
filename
)

For generating a export script file, this is the file which will be written.

public SchemaExport

Returns:

this
setOverrideOutputFileContent
()

For generating a export script file, by default the content will be appended at the begin or end of the file.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

appendback to summary
pack-priv boolean append
delimiterback to summary
pack-priv String delimiter
exceptionsback to summary
private final List<Exception> exceptions
formatback to summary
pack-priv boolean format
haltOnErrorback to summary
pack-priv boolean haltOnError
importFilesback to summary
private String importFiles
LOGback to summary
private static final CoreMessageLogger LOG
manageNamespacesback to summary
pack-priv boolean manageNamespaces
outputFileback to summary
pack-priv String outputFile

Constructor Detail

SchemaExportback to summary
public SchemaExport()

Method Detail

buildMetadataback to summary
private static MetadataImplementor buildMetadata(SchemaExport.CommandLineArgs parsedArgs, StandardServiceRegistry serviceRegistry) throws Exception
buildMetadataFromMainArgsback to summary
public static MetadataImplementor buildMetadataFromMainArgs(String[] args) throws Exception

Intended for test usage only. Builds a Metadata using the same algorithm as main

Parameters
args:String[]

The "command line args"

Returns:MetadataImplementor

The built Metadata

Exceptions
Exception:
Problems building the Metadata
buildStandardServiceRegistryback to summary
private static StandardServiceRegistry buildStandardServiceRegistry(SchemaExport.CommandLineArgs commandLineArgs) throws Exception
buildTargetDescriptorback to summary
public static TargetDescriptor buildTargetDescriptor(EnumSet<TargetType> targetTypes, String outputFile, ServiceRegistry serviceRegistry)
buildTargetDescriptorback to summary
public static TargetDescriptor buildTargetDescriptor(EnumSet<TargetType> targetTypes, String outputFile, boolean append, ServiceRegistry serviceRegistry)
createback to summary
public void create(EnumSet<TargetType> targetTypes, Metadata metadata)
createOnlyback to summary
public void createOnly(EnumSet<TargetType> targetTypes, Metadata metadata)
doExecutionback to summary
public void doExecution(SchemaExport.Action action, boolean needsJdbc, Metadata metadata, ServiceRegistry serviceRegistry, TargetDescriptor targetDescriptor)
dropback to summary
public void drop(EnumSet<TargetType> targetTypes, Metadata metadata)
executeback to summary
public void execute(EnumSet<TargetType> targetTypes, SchemaExport.Action action, Metadata metadata)
executeback to summary
public void execute(EnumSet<TargetType> targetTypes, SchemaExport.Action action, Metadata metadata, ServiceRegistry serviceRegistry)
Annotations
@SuppressWarnings:unchecked
executeback to summary
public static void execute(SchemaExport.CommandLineArgs commandLineArgs) throws Exception
getExceptionsback to summary
public List<E> getExceptions()

Returns a List of all Exceptions which occurred during the export.

Returns:List<E>

A List containing the Exceptions occurred during the export

mainback to summary
public static void main(String[] args)
needsJdbcConnectionback to summary
private boolean needsJdbcConnection(EnumSet<TargetType> targetTypes)
performback to summary
public void perform(SchemaExport.Action action, Metadata metadata, ScriptTargetOutput target)

For testing use

setDelimiterback to summary
public SchemaExport setDelimiter(String delimiter)

Set the end of statement delimiter

Parameters
delimiter:String

The delimiter

Returns:SchemaExport

this

setFormatback to summary
public SchemaExport setFormat(boolean format)

Should we format the sql strings?

Parameters
format:boolean

Should we format SQL strings

Returns:SchemaExport

this

setHaltOnErrorback to summary
public SchemaExport setHaltOnError(boolean haltOnError)

Should we stop once an error occurs?

Parameters
haltOnError:boolean

True if export should stop after error.

Returns:SchemaExport

this

setImportFilesback to summary
public SchemaExport setImportFiles(String importFiles)

Comma-separated list of resource names to use for database init commands on create.

Parameters
importFiles:String

The comma-separated list of init file resources names

Returns:SchemaExport

this

setManageNamespacesback to summary
public SchemaExport setManageNamespaces(boolean manageNamespaces)
setOutputFileback to summary
public SchemaExport setOutputFile(String filename)

For generating a export script file, this is the file which will be written.

Parameters
filename:String

The name of the file to which to write the export script.

Returns:SchemaExport

this

setOverrideOutputFileContentback to summary
public SchemaExport 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:SchemaExport

this

org.hibernate.tool.hbm2ddl back to summary

public final Enum SchemaExport.Action

extends Enum<SchemaExport.Action>
Class Inheritance

Field Summary

Modifier and TypeField and Description
public static final SchemaExport.Action
BOTH

Drop and then create

public static final SchemaExport.Action
CREATE

Create only

public static final SchemaExport.Action
DROP

Drop only

public static final SchemaExport.Action
NONE

None - duh :P

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public boolean
public boolean
private static SchemaExport.Action
interpret(boolean justDrop, boolean justCreate)

public static SchemaExport.Action
public static SchemaExport.Action
public static SchemaExport.Action[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

BOTHback to summary
public static final SchemaExport.Action BOTH

Drop and then create

CREATEback to summary
public static final SchemaExport.Action CREATE

Create only

DROPback to summary
public static final SchemaExport.Action DROP

Drop only

NONEback to summary
public static final SchemaExport.Action NONE

None - duh :P

Constructor Detail

Actionback to summary
private Action()

Method Detail

doCreateback to summary
public boolean doCreate()
doDropback to summary
public boolean doDrop()
interpretback to summary
private static SchemaExport.Action interpret(boolean justDrop, boolean justCreate)
parseCommandLineOptionback to summary
public static SchemaExport.Action parseCommandLineOption(String actionText)
valueOfback to summary
public static SchemaExport.Action valueOf(String name)
valuesback to summary
public static SchemaExport.Action[] values()
org.hibernate.tool.hbm2ddl back to summary

private Class SchemaExport.CommandLineArgs

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv SchemaExport.Action
pack-priv String
pack-priv String
pack-priv boolean
pack-priv boolean
pack-priv List<String>
pack-priv String
pack-priv String
pack-priv List<String>
pack-priv boolean
pack-priv String
pack-priv String
pack-priv String
pack-priv EnumSet<TargetType>

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static SchemaExport.CommandLineArgs
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

actionback to summary
pack-priv SchemaExport.Action action
cfgXmlFileback to summary
pack-priv String cfgXmlFile
delimiterback to summary
pack-priv String delimiter
formatback to summary
pack-priv boolean format
haltback to summary
pack-priv boolean halt
hbmXmlFilesback to summary
pack-priv List<String> hbmXmlFiles
implicitNamingStrategyImplNameback to summary
pack-priv String implicitNamingStrategyImplName
importFileback to summary
pack-priv String importFile
jarFilesback to summary
pack-priv List<String> jarFiles
manageNamespacesback to summary
pack-priv boolean manageNamespaces
outputFileback to summary
pack-priv String outputFile
physicalNamingStrategyImplNameback to summary
pack-priv String physicalNamingStrategyImplName
propertiesFileback to summary
pack-priv String propertiesFile
targetTypesback to summary
pack-priv EnumSet<TargetType> targetTypes

Constructor Detail

CommandLineArgsback to summary
private CommandLineArgs()

Method Detail

parseCommandLineArgsback to summary
public static SchemaExport.CommandLineArgs parseCommandLineArgs(String[] args)
org.hibernate.tool.hbm2ddl back to summary

private Class SchemaExport.TargetDescriptorImpl

extends Object
implements TargetDescriptor
Class Inheritance
All Implemented Interfaces
org.hibernate.tool.schema.spi.TargetDescriptor

Field Summary

Modifier and TypeField and Description
private final ScriptTargetOutput
private final EnumSet<TargetType>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public ScriptTargetOutput
getScriptTargetOutput()

Implements org.hibernate.tool.schema.spi.TargetDescriptor.getScriptTargetOutput.

If getTargetTypes() includes scripts, return a representation of the script file to write to.
public EnumSet<TargetType>
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

scriptTargetback to summary
private final ScriptTargetOutput scriptTarget
targetTypesback to summary
private final EnumSet<TargetType> targetTypes

Constructor Detail

TargetDescriptorImplback to summary
public TargetDescriptorImpl(EnumSet<TargetType> targetTypes, ScriptTargetOutput scriptTarget)

Method Detail

getScriptTargetOutputback to summary
public ScriptTargetOutput getScriptTargetOutput()

Implements org.hibernate.tool.schema.spi.TargetDescriptor.getScriptTargetOutput.

Doc from org.hibernate.tool.schema.spi.TargetDescriptor.getScriptTargetOutput.

If getTargetTypes() includes scripts, return a representation of the script file to write to. Otherwise, returns null.

While it is ultimately up to the actual tooling provider, it is generally an error for getTargetTypes() to indicate that scripts are a target and for this method to return null.

Returns:ScriptTargetOutput

The script output target

Annotations
@Override
getTargetTypesback to summary
public EnumSet<TargetType> getTargetTypes()

Implements org.hibernate.tool.schema.spi.TargetDescriptor.getTargetTypes.

Doc from org.hibernate.tool.schema.spi.TargetDescriptor.getTargetTypes.

The target type described here.

Returns:EnumSet<TargetType>

The target type.

Annotations
@Override
org.hibernate.tool.hbm2ddl back to summary

public final Enum SchemaExport.Type

extends Enum<SchemaExport.Type>
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final SchemaExport.Action
public static final SchemaExport.Type
public static final SchemaExport.Type
public static final SchemaExport.Type
public static final SchemaExport.Type

Constructor Summary

AccessConstructor and Description
private
Type(SchemaExport.Action actionReplacement)

Method Summary

Modifier and TypeMethod and Description
public boolean
public boolean
public static SchemaExport.Type
public static SchemaExport.Type[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

actionReplacementback to summary
private final SchemaExport.Action actionReplacement
BOTHback to summary
public static final SchemaExport.Type BOTH
CREATEback to summary
public static final SchemaExport.Type CREATE
DROPback to summary
public static final SchemaExport.Type DROP
NONEback to summary
public static final SchemaExport.Type NONE

Constructor Detail

Typeback to summary
private Type(SchemaExport.Action actionReplacement)

Method Detail

doCreateback to summary
public boolean doCreate()
doDropback to summary
public boolean doDrop()
valueOfback to summary
public static SchemaExport.Type valueOf(String name)
valuesback to summary
public static SchemaExport.Type[] values()