Top Description Inners Fields Constructors Methods
org.hibernate.tool.schema.internal

public Class SchemaCreatorImpl

extends Object
implements SchemaCreator
Class Inheritance
All Implemented Interfaces
org.hibernate.tool.schema.spi.SchemaCreator
Imports
java.net.URL, java.util.ArrayList, .Collections, .HashSet, .List, .Map, .Set, org.hibernate.Internal, org.hibernate.boot.Metadata, org.hibernate.boot.model.naming.Identifier, org.hibernate.boot.model.relational.AuxiliaryDatabaseObject, .Exportable, .InitCommand, .Namespace, .Sequence, .SqlStringGenerationContext, org.hibernate.boot.registry.classloading.spi.ClassLoaderService, org.hibernate.boot.spi.MetadataImplementor, org.hibernate.dialect.Dialect, org.hibernate.engine.config.spi.ConfigurationService, org.hibernate.engine.jdbc.env.spi.JdbcEnvironment, org.hibernate.engine.jdbc.internal.FormatStyle, .Formatter, org.hibernate.internal.CoreLogging, .CoreMessageLogger, org.hibernate.mapping.ForeignKey, .Index, .Table, .UniqueKey, .UserDefinedType, org.hibernate.service.ServiceRegistry, org.hibernate.service.spi.ServiceRegistryImplementor, org.hibernate.tool.schema.SourceType, org.hibernate.tool.schema.internal.exec.GenerationTarget, .JdbcContext, .ScriptSourceInputFromUrl, .ScriptSourceInputNonExistentImpl, org.hibernate.tool.schema.spi.ContributableMatcher, .ExceptionHandler, .ExecutionOptions, .SchemaCreator, .SchemaFilter, .SchemaManagementException, .SchemaManagementTool, .ScriptSourceInput, .SourceDescriptor, .SqlScriptCommandExtractor, .TargetDescriptor

Basic implementation of SchemaCreator.
Author
Steve Ebersole

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
public static final String
private static final CoreMessageLogger
private final SchemaFilter
private final HibernateSchemaManagementTool

Constructor Summary

AccessConstructor and Description
public
public
public
public
SchemaCreatorImpl(ServiceRegistry serviceRegistry, SchemaFilter schemaFilter)

Method Summary

Modifier and TypeMethod and Description
private void
applyImportFiles(ExecutionOptions options, SqlScriptCommandExtractor commandExtractor, Dialect dialect, Formatter formatter, String defaultImportFile, GenerationTarget[] targets)

Handles import scripts specified using org.hibernate.cfg.AvailableSettings#JAKARTA_HBM2DDL_LOAD_SCRIPT_SOURCE.

private boolean

Returns:

true if the legacy default import file was one of the listed imported files that were executed
applyImportScript
(ExecutionOptions options, SqlScriptCommandExtractor commandExtractor, Dialect dialect, Formatter formatter, GenerationTarget[] targets)

Handles import scripts specified using org.hibernate.cfg.AvailableSettings#HBM2DDL_IMPORT_FILES.

private void
applyImportSources(ExecutionOptions options, SqlScriptCommandExtractor commandExtractor, boolean format, Dialect dialect, GenerationTarget... targets)

private static void
checkExportIdentifier(Exportable exportable, Set<String> exportIdentifiers)

private boolean
private static void
createAuxiliaryObjectsAfterTables(Metadata metadata, ExecutionOptions options, Dialect dialect, Formatter formatter, SqlStringGenerationContext context, Set<String> exportIdentifiers, GenerationTarget[] targets)

Deprecated as a consequence of Metadata being deprecated.
private static void
createAuxiliaryObjectsBeforeTables(Metadata metadata, ExecutionOptions options, Dialect dialect, Formatter formatter, SqlStringGenerationContext context, Set<String> exportIdentifiers, GenerationTarget[] targets)

Deprecated as a consequence of Metadata being deprecated.
private static void
createForeignKeys(Metadata metadata, ExecutionOptions options, ContributableMatcher contributableInclusionMatcher, Dialect dialect, Formatter formatter, SqlStringGenerationContext context, GenerationTarget[] targets)

Deprecated as a consequence of Metadata being deprecated.
public void
createFromMetadata(Metadata metadata, ExecutionOptions options, Dialect dialect, Formatter formatter, GenerationTarget... targets)

Deprecated as a consequence of Metadata being deprecated.
public void
createFromMetadata(Metadata metadata, ExecutionOptions options, ContributableMatcher contributableInclusionMatcher, Dialect dialect, Formatter formatter, GenerationTarget... targets)

Deprecated as a consequence of Metadata being deprecated.
public void
createFromScript(ScriptSourceInput scriptSourceInput, SqlScriptCommandExtractor commandExtractor, Formatter formatter, Dialect dialect, ExecutionOptions options, GenerationTarget... targets)

private static void
createSchemasAndCatalogs(Metadata metadata, ExecutionOptions options, Dialect dialect, Formatter formatter, SqlStringGenerationContext context, GenerationTarget[] targets)

Deprecated as a consequence of Metadata being deprecated.
private static void
createSequences(Metadata metadata, ExecutionOptions options, ContributableMatcher contributableInclusionMatcher, Dialect dialect, Formatter formatter, SqlStringGenerationContext context, Set<String> exportIdentifiers, GenerationTarget[] targets, Namespace namespace)

Deprecated as a consequence of Metadata being deprecated.
private static void
createSequencesTablesConstraints(Metadata metadata, ExecutionOptions options, ContributableMatcher contributableInclusionMatcher, Dialect dialect, Formatter formatter, SqlStringGenerationContext context, Set<String> exportIdentifiers, GenerationTarget[] targets)

Deprecated as a consequence of Metadata being deprecated.
private static void
createTableConstraints(Metadata metadata, ExecutionOptions options, ContributableMatcher contributableInclusionMatcher, Dialect dialect, Formatter formatter, SqlStringGenerationContext context, Set<String> exportIdentifiers, GenerationTarget[] targets, Namespace namespace)

Deprecated as a consequence of Metadata being deprecated.
private static void
createTables(Metadata metadata, ExecutionOptions options, ContributableMatcher contributableInclusionMatcher, Dialect dialect, Formatter formatter, SqlStringGenerationContext context, Set<String> exportIdentifiers, GenerationTarget[] targets, Namespace namespace)

Deprecated as a consequence of Metadata being deprecated.
private static void
createUserDefinedTypes(Metadata metadata, ExecutionOptions options, Dialect dialect, Formatter formatter, SqlStringGenerationContext context, GenerationTarget[] targets)

Deprecated as a consequence of Metadata being deprecated.
public void
doCreation(Metadata
Represents the schema to be created.
metadata
,
ExecutionOptions
Options for executing the creation
options
,
ContributableMatcher
Filter for Contributable instances to use
contributableInclusionFilter
,
SourceDescriptor
description of the source(s) of creation commands
sourceDescriptor
,
TargetDescriptor
description of the target(s) for the creation commands
targetDescriptor
)

Implements org.hibernate.tool.schema.spi.SchemaCreator.doCreation.

Deprecated as a consequence of Metadata being deprecated.
Perform a schema creation from the indicated source(s) to the indicated target(s).
public void
doCreation(Metadata metadata, Dialect dialect, ExecutionOptions options, ContributableMatcher contributableInclusionFilter, SourceDescriptor sourceDescriptor, GenerationTarget... targets)

Deprecated as a consequence of Metadata being deprecated.
public void
doCreation(Metadata metadata, final boolean manageNamespaces, GenerationTarget... targets)

Deprecated as a consequence of Metadata being deprecated.
Intended for use from tests
public void
doCreation(Metadata metadata, final ServiceRegistry serviceRegistry, final Map<String, Object> settings, final boolean manageNamespaces, GenerationTarget... targets)

Deprecated as a consequence of Metadata being deprecated.
Intended for use from tests
private static void
executeInitCommands(Metadata metadata, ExecutionOptions options, Formatter formatter, GenerationTarget[] targets)

Deprecated as a consequence of Metadata being deprecated.
public List<String>

Returns:

The generation commands
generateCreationCommands
(Metadata
The metadata for which to generate the creation commands.
metadata
,
final boolean manageNamespaces)

Deprecated as a consequence of Metadata being deprecated.
For testing...
private static String
private ClassLoaderService
private SqlScriptCommandExtractor
private static Formatter
getImportScriptFormatter(boolean format)

In principle, we should format the commands in the import script if the format parameter is true, and since it's supposed to be a list of DML statements, we should use the basic DML formatter to do that.

private static Object

Returns:

a java.io.Reader or a string URL
getImportScriptSetting
(ExecutionOptions options)

private ScriptSourceInput
interpretLegacyImportScriptSetting(String resourceName, ClassLoaderService classLoaderService, String charsetName)

private void
performCreation(Metadata metadata, Dialect dialect, ExecutionOptions options, ContributableMatcher contributableInclusionFilter, SourceDescriptor sourceDescriptor, GenerationTarget... targets)

Deprecated as a consequence of Metadata being deprecated.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

DEFAULT_IMPORT_FILEback to summary
public static final String DEFAULT_IMPORT_FILE
logback to summary
private static final CoreMessageLogger log
schemaFilterback to summary
private final SchemaFilter schemaFilter
toolback to summary
private final HibernateSchemaManagementTool tool

Constructor Detail

SchemaCreatorImplback to summary
public SchemaCreatorImpl(HibernateSchemaManagementTool tool)
SchemaCreatorImplback to summary
public SchemaCreatorImpl(HibernateSchemaManagementTool tool, SchemaFilter schemaFilter)
SchemaCreatorImplback to summary
public SchemaCreatorImpl(ServiceRegistry serviceRegistry)
SchemaCreatorImplback to summary
public SchemaCreatorImpl(ServiceRegistry serviceRegistry, SchemaFilter schemaFilter)

Method Detail

applyImportFilesback to summary
private void applyImportFiles(ExecutionOptions options, SqlScriptCommandExtractor commandExtractor, Dialect dialect, Formatter formatter, String defaultImportFile, GenerationTarget[] targets)

Handles import scripts specified using org.hibernate.cfg.AvailableSettings#JAKARTA_HBM2DDL_LOAD_SCRIPT_SOURCE.

applyImportScriptback to summary
private boolean applyImportScript(ExecutionOptions options, SqlScriptCommandExtractor commandExtractor, Dialect dialect, Formatter formatter, GenerationTarget[] targets)

Handles import scripts specified using org.hibernate.cfg.AvailableSettings#HBM2DDL_IMPORT_FILES.

Returns:boolean

true if the legacy default import file was one of the listed imported files that were executed

applyImportSourcesback to summary
private void applyImportSources(ExecutionOptions options, SqlScriptCommandExtractor commandExtractor, boolean format, Dialect dialect, GenerationTarget... targets)
checkExportIdentifierback to summary
private static void checkExportIdentifier(Exportable exportable, Set<String> exportIdentifiers)
containsDefaultImportFileback to summary
private boolean containsDefaultImportFile(ScriptSourceInput importScriptInput)
createAuxiliaryObjectsAfterTablesback to summary
private static void createAuxiliaryObjectsAfterTables(Metadata metadata, ExecutionOptions options, Dialect dialect, Formatter formatter, SqlStringGenerationContext context, Set<String> exportIdentifiers, GenerationTarget[] targets)

Deprecated

as a consequence of Metadata being deprecated. See corresponding docs for further information.

createAuxiliaryObjectsBeforeTablesback to summary
private static void createAuxiliaryObjectsBeforeTables(Metadata metadata, ExecutionOptions options, Dialect dialect, Formatter formatter, SqlStringGenerationContext context, Set<String> exportIdentifiers, GenerationTarget[] targets)

Deprecated

as a consequence of Metadata being deprecated. See corresponding docs for further information.

createForeignKeysback to summary
private static void createForeignKeys(Metadata metadata, ExecutionOptions options, ContributableMatcher contributableInclusionMatcher, Dialect dialect, Formatter formatter, SqlStringGenerationContext context, GenerationTarget[] targets)

Deprecated

as a consequence of Metadata being deprecated. See corresponding docs for further information.

createFromMetadataback to summary
public void createFromMetadata(Metadata metadata, ExecutionOptions options, Dialect dialect, Formatter formatter, GenerationTarget... targets)

Deprecated

as a consequence of Metadata being deprecated. See corresponding docs for further information.

Annotations
@Internal
createFromMetadataback to summary
public void createFromMetadata(Metadata metadata, ExecutionOptions options, ContributableMatcher contributableInclusionMatcher, Dialect dialect, Formatter formatter, GenerationTarget... targets)

Deprecated

as a consequence of Metadata being deprecated. See corresponding docs for further information.

Annotations
@Internal
createFromScriptback to summary
public void createFromScript(ScriptSourceInput scriptSourceInput, SqlScriptCommandExtractor commandExtractor, Formatter formatter, Dialect dialect, ExecutionOptions options, GenerationTarget... targets)
createSchemasAndCatalogsback to summary
private static void createSchemasAndCatalogs(Metadata metadata, ExecutionOptions options, Dialect dialect, Formatter formatter, SqlStringGenerationContext context, GenerationTarget[] targets)

Deprecated

as a consequence of Metadata being deprecated. See corresponding docs for further information.

createSequencesback to summary
private static void createSequences(Metadata metadata, ExecutionOptions options, ContributableMatcher contributableInclusionMatcher, Dialect dialect, Formatter formatter, SqlStringGenerationContext context, Set<String> exportIdentifiers, GenerationTarget[] targets, Namespace namespace)

Deprecated

as a consequence of Metadata being deprecated. See corresponding docs for further information.

createSequencesTablesConstraintsback to summary
private static void createSequencesTablesConstraints(Metadata metadata, ExecutionOptions options, ContributableMatcher contributableInclusionMatcher, Dialect dialect, Formatter formatter, SqlStringGenerationContext context, Set<String> exportIdentifiers, GenerationTarget[] targets)

Deprecated

as a consequence of Metadata being deprecated. See corresponding docs for further information.

createTableConstraintsback to summary
private static void createTableConstraints(Metadata metadata, ExecutionOptions options, ContributableMatcher contributableInclusionMatcher, Dialect dialect, Formatter formatter, SqlStringGenerationContext context, Set<String> exportIdentifiers, GenerationTarget[] targets, Namespace namespace)

Deprecated

as a consequence of Metadata being deprecated. See corresponding docs for further information.

createTablesback to summary
private static void createTables(Metadata metadata, ExecutionOptions options, ContributableMatcher contributableInclusionMatcher, Dialect dialect, Formatter formatter, SqlStringGenerationContext context, Set<String> exportIdentifiers, GenerationTarget[] targets, Namespace namespace)

Deprecated

as a consequence of Metadata being deprecated. See corresponding docs for further information.

createUserDefinedTypesback to summary
private static void createUserDefinedTypes(Metadata metadata, ExecutionOptions options, Dialect dialect, Formatter formatter, SqlStringGenerationContext context, GenerationTarget[] targets)

Deprecated

as a consequence of Metadata being deprecated. See corresponding docs for further information.

doCreationback to summary
public void doCreation(Metadata metadata, ExecutionOptions options, ContributableMatcher contributableInclusionFilter, SourceDescriptor sourceDescriptor, TargetDescriptor targetDescriptor)

Implements org.hibernate.tool.schema.spi.SchemaCreator.doCreation.

Doc from org.hibernate.tool.schema.spi.SchemaCreator.doCreation.

Deprecated

as a consequence of Metadata being deprecated. See corresponding docs for further information.

Perform a schema creation from the indicated source(s) to the indicated target(s).

Parameters
metadata:Metadata

Represents the schema to be created.

options:ExecutionOptions

Options for executing the creation

contributableInclusionFilter:ContributableMatcher

Filter for Contributable instances to use

sourceDescriptor:SourceDescriptor

description of the source(s) of creation commands

targetDescriptor:TargetDescriptor

description of the target(s) for the creation commands

Annotations
@Override
doCreationback to summary
public void doCreation(Metadata metadata, Dialect dialect, ExecutionOptions options, ContributableMatcher contributableInclusionFilter, SourceDescriptor sourceDescriptor, GenerationTarget... targets)

Deprecated

as a consequence of Metadata being deprecated. See corresponding docs for further information.

Annotations
@Internal
doCreationback to summary
public void doCreation(Metadata metadata, final boolean manageNamespaces, GenerationTarget... targets)

Deprecated

as a consequence of Metadata being deprecated. See corresponding docs for further information.

Intended for use from tests

Annotations
@Internal
doCreationback to summary
public void doCreation(Metadata metadata, final ServiceRegistry serviceRegistry, final Map<String, Object> settings, final boolean manageNamespaces, GenerationTarget... targets)

Deprecated

as a consequence of Metadata being deprecated. See corresponding docs for further information.

Intended for use from tests

Annotations
@Internal
executeInitCommandsback to summary
private static void executeInitCommands(Metadata metadata, ExecutionOptions options, Formatter formatter, GenerationTarget[] targets)

Deprecated

as a consequence of Metadata being deprecated. See corresponding docs for further information.

generateCreationCommandsback to summary
public List<String> generateCreationCommands(Metadata metadata, final boolean manageNamespaces)

Deprecated

as a consequence of Metadata being deprecated. See corresponding docs for further information.

For testing...

Parameters
metadata:Metadata

The metadata for which to generate the creation commands.

Returns:List<String>

The generation commands

getCharsetNameback to summary
private static String getCharsetName(ExecutionOptions options)
See Also
org.hibernate.cfg.AvailableSettings#HBM2DDL_CHARSET_NAME
getClassLoaderServiceback to summary
private ClassLoaderService getClassLoaderService()
getCommandExtractorback to summary
private SqlScriptCommandExtractor getCommandExtractor()
getImportScriptFormatterback to summary
private static Formatter getImportScriptFormatter(boolean format)

In principle, we should format the commands in the import script if the format parameter is true, and since it's supposed to be a list of DML statements, we should use the basic DML formatter to do that. However, in practice we don't really know much about what this file contains, and we have never formatted it in the past, so there's no compelling reason to start now. In fact, if we have lists of many insert statements on the same table, which is what we typically expect, it's probably better to not format.

getImportScriptSettingback to summary
private static Object getImportScriptSetting(ExecutionOptions options)
Returns:Object

a java.io.Reader or a string URL

See Also
org.hibernate.cfg.AvailableSettings#JAKARTA_HBM2DDL_LOAD_SCRIPT_SOURCE
interpretLegacyImportScriptSettingback to summary
private ScriptSourceInput interpretLegacyImportScriptSetting(String resourceName, ClassLoaderService classLoaderService, String charsetName)
performCreationback to summary
private void performCreation(Metadata metadata, Dialect dialect, ExecutionOptions options, ContributableMatcher contributableInclusionFilter, SourceDescriptor sourceDescriptor, GenerationTarget... targets)

Deprecated

as a consequence of Metadata being deprecated. See corresponding docs for further information.

org.hibernate.tool.schema.internal back to summary

private Class SchemaCreatorImpl.JournalingGenerationTarget

extends Object
implements GenerationTarget
Class Inheritance
  • java.lang.Object
  • org.hibernate.tool.schema.internal.SchemaCreatorImpl.JournalingGenerationTarget
All Implemented Interfaces
org.hibernate.tool.schema.internal.exec.GenerationTarget

Field Summary

Modifier and TypeField and Description
private final ArrayList<String>

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public void
accept(String
The command
command
)

Implements org.hibernate.tool.schema.internal.exec.GenerationTarget.accept.

Accept a command
public void
public void
release()

Implements org.hibernate.tool.schema.internal.exec.GenerationTarget.release.

Release this target, giving it a change to release its resources.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

commandsback to summary
private final ArrayList<String> commands

Constructor Detail

JournalingGenerationTargetback to summary
private JournalingGenerationTarget()

Method Detail

acceptback to summary
public void accept(String command)

Implements org.hibernate.tool.schema.internal.exec.GenerationTarget.accept.

Doc from org.hibernate.tool.schema.internal.exec.GenerationTarget.accept.

Accept a command

Parameters
command:String

The command

Annotations
@Override
prepareback to summary
public void prepare()

Implements org.hibernate.tool.schema.internal.exec.GenerationTarget.prepare.

Doc from org.hibernate.tool.schema.internal.exec.GenerationTarget.prepare.

Prepare for accepting actions

Annotations
@Override
releaseback to summary
public void release()

Implements org.hibernate.tool.schema.internal.exec.GenerationTarget.release.

Doc from org.hibernate.tool.schema.internal.exec.GenerationTarget.release.

Release this target, giving it a change to release its resources.

Annotations
@Override