Top Description Methods
org.hibernate.boot

public Interface MetadataBuilder

Known Direct Subinterfaces
org.hibernate.boot.spi.MetadataBuilderImplementor
Imports
javax.persistence.AttributeConverter, .SharedCacheMode, org.hibernate.annotations.common.reflection.ReflectionManager, org.hibernate.boot.archive.scan.spi.ScanEnvironment, .ScanOptions, .Scanner, org.hibernate.boot.archive.spi.ArchiveDescriptorFactory, org.hibernate.boot.model.IdGeneratorStrategyInterpreter, .TypeContributor, org.hibernate.boot.model.naming.ImplicitNamingStrategy, .PhysicalNamingStrategy, org.hibernate.boot.model.relational.AuxiliaryDatabaseObject, org.hibernate.cache.spi.access.AccessType, org.hibernate.cfg.AttributeConverterDefinition, .MetadataSourceType, org.hibernate.dialect.function.SQLFunction, org.hibernate.type.BasicType, org.hibernate.usertype.CompositeUserType, .UserType, org.jboss.jandex.IndexView

Contract for specifying various overrides to be used in metamodel building.
Authors
Steve Ebersole, Hardy Ferentschik
Since
5.0

Method Summary

Modifier and TypeMethod and Description
public MetadataBuilder

Returns:

this, for method chaining
applyAccessType
(AccessType
The access-type to use as default.
accessType
)

Specify the second-level access-type to be used by default for entities and collections that define second-level caching, but do not specify a granular access-type.

public MetadataBuilder

Returns:

this, for method chaining
applyArchiveDescriptorFactory
(ArchiveDescriptorFactory
The ArchiveDescriptorFactory to use.
factory
)

Specify a particular ArchiveDescriptorFactory instance to use in scanning.

public MetadataBuilder

Returns:

this for method chaining
applyAttributeConverter
(AttributeConverterDefinition
The definition
definition
)

Deprecated (since 5.3) AttributeConverterDefinition forces early access to the AttributeConverter instance which precludes the possibility to resolve the converter from CDI, etc. Instead use one of: * applyAttributeConverter(Class) * applyAttributeConverter(Class, boolean) * applyAttributeConverter(AttributeConverter) * applyAttributeConverter(AttributeConverter, boolean)
Adds an AttributeConverter by an AttributeConverterDefinition
public MetadataBuilder

Returns:

this for method chaining
applyAttributeConverter
(Class<? extends AttributeConverter<X, Y>>
The AttributeConverter class.
attributeConverterClass
)

Adds an AttributeConverter by its Class.

public MetadataBuilder

Returns:

this for method chaining
applyAttributeConverter
(Class<? extends AttributeConverter<X, Y>>
The AttributeConverter class.
attributeConverterClass
,
boolean
Should the AttributeConverter be auto applied to property types as specified by its "entity attribute" parameterized type?
autoApply
)

Adds an AttributeConverter by its Class plus a boolean indicating whether to auto apply it.

public MetadataBuilder

Returns:

this for method chaining
applyAttributeConverter
(AttributeConverter<X, Y>
The AttributeConverter instance.
attributeConverter
)

Adds an AttributeConverter instance.

public MetadataBuilder

Returns:

this for method chaining
applyAttributeConverter
(AttributeConverter<X, Y>
The AttributeConverter instance.
attributeConverter
,
boolean
Should the AttributeConverter be auto applied to property types as specified by its "entity attribute" parameterized type?
autoApply
)

Adds an AttributeConverter instance, explicitly indicating whether to auto-apply.

public MetadataBuilder
public MetadataBuilder

Returns:

this, for method chaining
applyBasicType
(BasicType
The type addition or override.
type
)

Specify an additional or overridden basic type mapping.

public MetadataBuilder

Returns:

this, for method chaining
applyBasicType
(BasicType
The type addition or override.
type
,
String...
The keys under which to register the basic type.
keys
)

Specify an additional or overridden basic type mapping supplying specific registration keys.

public MetadataBuilder

Returns:

this, for method chaining
applyBasicType
(UserType
The custom type
type
,
String...
The keys under which to register the custom type.
keys
)

Register an additional or overridden custom type mapping.

public MetadataBuilder

Returns:

this, for method chaining
applyBasicType
(CompositeUserType
The composite custom type
type
,
String...
The keys under which to register the composite custom type.
keys
)

Register an additional or overridden composite custom type mapping.

public MetadataBuilder

Returns:

this, for method chaining
applyCacheRegionDefinition
(CacheRegionDefinition
The cache region definition to apply
cacheRegionDefinition
)

Apply a CacheRegionDefinition to be applied to an entity, collection or query while building the Metadata object.

public MetadataBuilder
public MetadataBuilder

Returns:

this, for method chaining
applyImplicitCatalogName
(String
The implicit catalog name
implicitCatalogName
)

Specify the implicit catalog name to apply to any unqualified database names.

public MetadataBuilder

Returns:

this, for method chaining
applyImplicitNamingStrategy
(ImplicitNamingStrategy
The ImplicitNamingStrategy to apply
namingStrategy
)

Specify the ImplicitNamingStrategy to use in building the Metadata.

public MetadataBuilder

Returns:

this, for method chaining
applyImplicitSchemaName
(String
The implicit schema name
implicitSchemaName
)

Specify the implicit schema name to apply to any unqualified database names.

public MetadataBuilder

Returns:

this, for method chaining
applyIndexView
(IndexView
The Jandex index to use.
jandexView
)

Allows specifying a specific Jandex index to use for reading annotation information.

public MetadataBuilder

Returns:

this, for method chaining
applyPhysicalNamingStrategy
(PhysicalNamingStrategy
The PhysicalNamingStrategy to apply
namingStrategy
)

Specify the PhysicalNamingStrategy to use in building the Metadata.

public MetadataBuilder

Returns:

this, for method chaining
applyScanEnvironment
(ScanEnvironment
The environment for scanning
scanEnvironment
)

Consider this temporary as discussed on ScanEnvironment

public MetadataBuilder

Returns:

this, for method chaining
applyScanner
(Scanner
The scanner to use.
scanner
)

Specify a particular Scanner instance to use.

public MetadataBuilder

Returns:

this, for method chaining
applyScanOptions
(ScanOptions
The scan options.
scanOptions
)

Specify the options to be used in performing scanning.

public MetadataBuilder

Returns:

this, for method chaining
applySharedCacheMode
(SharedCacheMode
The cache mode.
cacheMode
)

Specify the second-level cache mode to be used.

public MetadataBuilder

Returns:

this for method chaining
applySourceProcessOrdering
(MetadataSourceType...
The types, in the order they should be processed
sourceTypes
)

Apply a specific ordering to the processing of sources.

public MetadataBuilder
applySqlFunction(String functionName, SQLFunction function)

public MetadataBuilder

Returns:

this, for method chaining
applyTempClassLoader
(ClassLoader
ClassLoader for use during building the Metadata
tempClassLoader
)

Apply a ClassLoader for use while building the Metadata.

public MetadataBuilder

Returns:

this, for method chaining
applyTypes
(TypeContributor
The contributor to apply
typeContributor
)

Apply an explicit TypeContributor (implicit application via ServiceLoader will still happen too)

public Metadata

Returns:

The built metadata.
build
()

Actually build the metamodel

public MetadataBuilder

Returns:

this, for method chaining
enableExplicitDiscriminatorsForJoinedSubclassSupport
(boolean
Should processing (not ignoring) explicit discriminators be enabled?
enabled
)

Should we process or ignore explicitly defined discriminators in the case of joined-subclasses.

public MetadataBuilder

Returns:

this, for method chaining
enableGlobalNationalizedCharacterDataSupport
(boolean
true says to use nationalized variants; false says to use the non-nationalized variants.
enabled
)

Should nationalized variants of character data be used in the database types?

public MetadataBuilder

Returns:

this, for method chaining
enableImplicitDiscriminatorsForJoinedSubclassSupport
(boolean
Should we implicitly create discriminator for joined inheritance if one is not explicitly mentioned?
enabled
)

Similarly to enableExplicitDiscriminatorsForJoinedSubclassSupport, but here how should we treat joined inheritance when there is no explicitly defined discriminator annotations?

public MetadataBuilder

Returns:

this, for method chaining
enableImplicitForcingOfDiscriminatorsInSelect
(boolean
true indicates we will force the discriminator into the select; false indicates we will not.
supported
)

For entities which do not explicitly say, should we force discriminators into SQL selects?

public MetadataBuilder

Returns:

this, for method chaining
enableNewIdentifierGeneratorSupport
(boolean
true to enable; false to disable; don't call for default.
enable
)

Should we enable support for the "new" (since 3.2) identifier generator mappings for handling:

public <T extends MetadataBuilder> T

Returns:

The unwrapped builder.
unwrap
(Class<T> type)

Allows unwrapping this builder as another, more specific type.

Method Detail

applyAccessTypeback to summary
public MetadataBuilder applyAccessType(AccessType accessType)

Specify the second-level access-type to be used by default for entities and collections that define second-level caching, but do not specify a granular access-type.

Its default is defined by the org.hibernate.cfg.AvailableSettings#DEFAULT_CACHE_CONCURRENCY_STRATEGY setting if using property-based configuration.

Parameters
accessType:AccessType

The access-type to use as default.

Returns:MetadataBuilder

this, for method chaining

See Also
org.hibernate.cfg.AvailableSettings#DEFAULT_CACHE_CONCURRENCY_STRATEGY, applySharedCacheMode(javax.persistence.SharedCacheMode)
applyArchiveDescriptorFactoryback to summary
public MetadataBuilder applyArchiveDescriptorFactory(ArchiveDescriptorFactory factory)

Specify a particular ArchiveDescriptorFactory instance to use in scanning.

Its default is defined by the org.hibernate.cfg.AvailableSettings#SCANNER_ARCHIVE_INTERPRETER setting if using property-based configuration.

Parameters
factory:ArchiveDescriptorFactory

The ArchiveDescriptorFactory to use.

Returns:MetadataBuilder

this, for method chaining

See Also
org.hibernate.cfg.AvailableSettings#SCANNER_ARCHIVE_INTERPRETER
applyAttributeConverterback to summary
public MetadataBuilder applyAttributeConverter(AttributeConverterDefinition definition)

Deprecated

(since 5.3) AttributeConverterDefinition forces early access to the AttributeConverter instance which precludes the possibility to resolve the converter from CDI, etc. Instead use one of: * applyAttributeConverter(Class) * applyAttributeConverter(Class, boolean) * applyAttributeConverter(AttributeConverter) * applyAttributeConverter(AttributeConverter, boolean)

Adds an AttributeConverter by an AttributeConverterDefinition

Parameters
definition:AttributeConverterDefinition

The definition

Returns:MetadataBuilder

this for method chaining

Annotations
@Deprecated
applyAttributeConverterback to summary
public MetadataBuilder applyAttributeConverter(Class<? extends AttributeConverter<X, Y>> attributeConverterClass)

Adds an AttributeConverter by its Class.

Parameters
attributeConverterClass:Class<? extends AttributeConverter<X, Y>>

The AttributeConverter class.

Returns:MetadataBuilder

this for method chaining

applyAttributeConverterback to summary
public MetadataBuilder applyAttributeConverter(Class<? extends AttributeConverter<X, Y>> attributeConverterClass, boolean autoApply)

Adds an AttributeConverter by its Class plus a boolean indicating whether to auto apply it.

Parameters
attributeConverterClass:Class<? extends AttributeConverter<X, Y>>

The AttributeConverter class.

autoApply:boolean

Should the AttributeConverter be auto applied to property types as specified by its "entity attribute" parameterized type?

Returns:MetadataBuilder

this for method chaining

See Also
org.hibernate.cfg.AttributeConverterDefinition#from(Class, boolean)
applyAttributeConverterback to summary
public MetadataBuilder applyAttributeConverter(AttributeConverter<X, Y> attributeConverter)

Adds an AttributeConverter instance.

Parameters
attributeConverter:AttributeConverter<X, Y>

The AttributeConverter instance.

Returns:MetadataBuilder

this for method chaining

See Also
org.hibernate.cfg.AttributeConverterDefinition#from(AttributeConverter)
applyAttributeConverterback to summary
public MetadataBuilder applyAttributeConverter(AttributeConverter<X, Y> attributeConverter, boolean autoApply)

Adds an AttributeConverter instance, explicitly indicating whether to auto-apply.

Parameters
attributeConverter:AttributeConverter<X, Y>

The AttributeConverter instance.

autoApply:boolean

Should the AttributeConverter be auto applied to property types as specified by its "entity attribute" parameterized type?

Returns:MetadataBuilder

this for method chaining

See Also
org.hibernate.cfg.AttributeConverterDefinition#from(AttributeConverter, boolean)
applyAuxiliaryDatabaseObjectback to summary
public MetadataBuilder applyAuxiliaryDatabaseObject(AuxiliaryDatabaseObject auxiliaryDatabaseObject)
applyBasicTypeback to summary
public MetadataBuilder applyBasicType(BasicType type)

Specify an additional or overridden basic type mapping.

Parameters
type:BasicType

The type addition or override.

Returns:MetadataBuilder

this, for method chaining

applyBasicTypeback to summary
public MetadataBuilder applyBasicType(BasicType type, String... keys)

Specify an additional or overridden basic type mapping supplying specific registration keys.

Parameters
type:BasicType

The type addition or override.

keys:String[]

The keys under which to register the basic type.

Returns:MetadataBuilder

this, for method chaining

applyBasicTypeback to summary
public MetadataBuilder applyBasicType(UserType type, String... keys)

Register an additional or overridden custom type mapping.

Parameters
type:UserType

The custom type

keys:String[]

The keys under which to register the custom type.

Returns:MetadataBuilder

this, for method chaining

applyBasicTypeback to summary
public MetadataBuilder applyBasicType(CompositeUserType type, String... keys)

Register an additional or overridden composite custom type mapping.

Parameters
type:CompositeUserType

The composite custom type

keys:String[]

The keys under which to register the composite custom type.

Returns:MetadataBuilder

this, for method chaining

applyCacheRegionDefinitionback to summary
public MetadataBuilder applyCacheRegionDefinition(CacheRegionDefinition cacheRegionDefinition)

Apply a CacheRegionDefinition to be applied to an entity, collection or query while building the Metadata object.

Parameters
cacheRegionDefinition:CacheRegionDefinition

The cache region definition to apply

Returns:MetadataBuilder

this, for method chaining

applyIdGenerationTypeInterpreterback to summary
public MetadataBuilder applyIdGenerationTypeInterpreter(IdGeneratorStrategyInterpreter interpreter)
applyImplicitCatalogNameback to summary
public MetadataBuilder applyImplicitCatalogName(String implicitCatalogName)

Specify the implicit catalog name to apply to any unqualified database names.

Its default is defined by the org.hibernate.cfg.AvailableSettings#DEFAULT_CATALOG setting if using property-based configuration.

Parameters
implicitCatalogName:String

The implicit catalog name

Returns:MetadataBuilder

this, for method chaining

See Also
org.hibernate.cfg.AvailableSettings#DEFAULT_CATALOG
applyImplicitNamingStrategyback to summary
public MetadataBuilder applyImplicitNamingStrategy(ImplicitNamingStrategy namingStrategy)

Specify the ImplicitNamingStrategy to use in building the Metadata.

Its default is defined by the org.hibernate.cfg.AvailableSettings#IMPLICIT_NAMING_STRATEGY setting if using property-based configuration.

Parameters
namingStrategy:ImplicitNamingStrategy

The ImplicitNamingStrategy to apply

Returns:MetadataBuilder

this, for method chaining

See Also
org.hibernate.cfg.AvailableSettings#IMPLICIT_NAMING_STRATEGY
applyImplicitSchemaNameback to summary
public MetadataBuilder applyImplicitSchemaName(String implicitSchemaName)

Specify the implicit schema name to apply to any unqualified database names.

Its default is defined by the org.hibernate.cfg.AvailableSettings#DEFAULT_SCHEMA setting if using property-based configuration.

Parameters
implicitSchemaName:String

The implicit schema name

Returns:MetadataBuilder

this, for method chaining

See Also
org.hibernate.cfg.AvailableSettings#DEFAULT_SCHEMA
applyIndexViewback to summary
public MetadataBuilder applyIndexView(IndexView jandexView)

Allows specifying a specific Jandex index to use for reading annotation information.

It is important to understand that if a Jandex index is passed in, it is expected that this Jandex index already contains all entries for all classes. No additional indexing will be done in this case.

NOTE : Here for future expansion. At the moment the passed Jandex index is not used.

Parameters
jandexView:IndexView

The Jandex index to use.

Returns:MetadataBuilder

this, for method chaining

applyPhysicalNamingStrategyback to summary
public MetadataBuilder applyPhysicalNamingStrategy(PhysicalNamingStrategy namingStrategy)

Specify the PhysicalNamingStrategy to use in building the Metadata.

Its default is defined by the org.hibernate.cfg.AvailableSettings#PHYSICAL_NAMING_STRATEGY setting if using property-based configuration.

Parameters
namingStrategy:PhysicalNamingStrategy

The PhysicalNamingStrategy to apply

Returns:MetadataBuilder

this, for method chaining

See Also
org.hibernate.cfg.AvailableSettings#PHYSICAL_NAMING_STRATEGY
applyScanEnvironmentback to summary
public MetadataBuilder applyScanEnvironment(ScanEnvironment scanEnvironment)

Consider this temporary as discussed on ScanEnvironment

Parameters
scanEnvironment:ScanEnvironment

The environment for scanning

Returns:MetadataBuilder

this, for method chaining

applyScannerback to summary
public MetadataBuilder applyScanner(Scanner scanner)

Specify a particular Scanner instance to use.

Its default is defined by the org.hibernate.cfg.AvailableSettings#SCANNER setting if using property-based configuration.

Parameters
scanner:Scanner

The scanner to use.

Returns:MetadataBuilder

this, for method chaining

See Also
org.hibernate.cfg.AvailableSettings#SCANNER
applyScanOptionsback to summary
public MetadataBuilder applyScanOptions(ScanOptions scanOptions)

Specify the options to be used in performing scanning.

Parameters
scanOptions:ScanOptions

The scan options.

Returns:MetadataBuilder

this, for method chaining

See Also
org.hibernate.cfg.AvailableSettings#SCANNER_DISCOVERY
applySharedCacheModeback to summary
public MetadataBuilder applySharedCacheMode(SharedCacheMode cacheMode)

Specify the second-level cache mode to be used. This is the cache mode in terms of whether or not to cache.

Its default is defined by the javax.persistence.sharedCache.mode setting if using property-based configuration.

Parameters
cacheMode:SharedCacheMode

The cache mode.

Returns:MetadataBuilder

this, for method chaining

See Also
applyAccessType
applySourceProcessOrderingback to summary
public MetadataBuilder applySourceProcessOrdering(MetadataSourceType... sourceTypes)

Apply a specific ordering to the processing of sources. Note that unlike most of the methods on this contract that deal with multiple values internally, this one *replaces* any already set (its more a setter) instead of adding to.

Its default is defined by the org.hibernate.cfg.AvailableSettings#ARTIFACT_PROCESSING_ORDER setting if using property-based configuration.

Parameters
sourceTypes:MetadataSourceType[]

The types, in the order they should be processed

Returns:MetadataBuilder

this for method chaining

See Also
org.hibernate.cfg.AvailableSettings#ARTIFACT_PROCESSING_ORDER
applySqlFunctionback to summary
public MetadataBuilder applySqlFunction(String functionName, SQLFunction function)
applyTempClassLoaderback to summary
public MetadataBuilder applyTempClassLoader(ClassLoader tempClassLoader)

Apply a ClassLoader for use while building the Metadata.

Ideally we should avoid accessing ClassLoaders when perform 1st phase of bootstrap. This is a ClassLoader that can be used in cases when we have to. IN EE managed environments, this is the ClassLoader mandated by javax.persistence.spi.PersistenceUnitInfo#getNewTempClassLoader(). This ClassLoader is thrown away by the container afterwards. The idea being that the Class can still be enhanced in the application ClassLoader. In other environments, pass a ClassLoader that performs the same function if desired.

Parameters
tempClassLoader:ClassLoader

ClassLoader for use during building the Metadata

Returns:MetadataBuilder

this, for method chaining

applyTypesback to summary
public MetadataBuilder applyTypes(TypeContributor typeContributor)

Apply an explicit TypeContributor (implicit application via ServiceLoader will still happen too)

Parameters
typeContributor:TypeContributor

The contributor to apply

Returns:MetadataBuilder

this, for method chaining

buildback to summary
public Metadata build()

Actually build the metamodel

Returns:Metadata

The built metadata.

enableExplicitDiscriminatorsForJoinedSubclassSupportback to summary
public MetadataBuilder enableExplicitDiscriminatorsForJoinedSubclassSupport(boolean enabled)

Should we process or ignore explicitly defined discriminators in the case of joined-subclasses. The legacy behavior of Hibernate was to ignore the discriminator annotations because Hibernate (unlike some providers) does not need discriminators to determine the concrete type when it comes to joined inheritance. However, for portability reasons we do now allow using explicit discriminators along with joined inheritance. It is configurable though to support legacy apps.

Its default is defined by the org.hibernate.cfg.AvailableSettings#IGNORE_EXPLICIT_DISCRIMINATOR_COLUMNS_FOR_JOINED_SUBCLASS setting if using property-based configuration.

Parameters
enabled:boolean

Should processing (not ignoring) explicit discriminators be enabled?

Returns:MetadataBuilder

this, for method chaining

See Also
org.hibernate.cfg.AvailableSettings#IGNORE_EXPLICIT_DISCRIMINATOR_COLUMNS_FOR_JOINED_SUBCLASS
enableGlobalNationalizedCharacterDataSupportback to summary
public MetadataBuilder enableGlobalNationalizedCharacterDataSupport(boolean enabled)

Should nationalized variants of character data be used in the database types? For example, should NVARCHAR be used instead of VARCHAR? NCLOB instead of CLOB?

Its default is defined by the org.hibernate.cfg.AvailableSettings#USE_NATIONALIZED_CHARACTER_DATA setting if using property-based configuration.

Parameters
enabled:boolean

true says to use nationalized variants; false says to use the non-nationalized variants.

Returns:MetadataBuilder

this, for method chaining

See Also
org.hibernate.cfg.AvailableSettings#USE_NATIONALIZED_CHARACTER_DATA
enableImplicitDiscriminatorsForJoinedSubclassSupportback to summary
public MetadataBuilder enableImplicitDiscriminatorsForJoinedSubclassSupport(boolean enabled)

Similarly to enableExplicitDiscriminatorsForJoinedSubclassSupport, but here how should we treat joined inheritance when there is no explicitly defined discriminator annotations? If enabled, we will handle joined inheritance with no explicit discriminator annotations by implicitly creating one (following the JPA implicit naming rules).

Again the premise here is JPA portability, bearing in mind that some JPA provider need these discriminators.

Its default is defined by the org.hibernate.cfg.AvailableSettings#IMPLICIT_DISCRIMINATOR_COLUMNS_FOR_JOINED_SUBCLASS setting if using property-based configuration.

Parameters
enabled:boolean

Should we implicitly create discriminator for joined inheritance if one is not explicitly mentioned?

Returns:MetadataBuilder

this, for method chaining

See Also
org.hibernate.cfg.AvailableSettings#IMPLICIT_DISCRIMINATOR_COLUMNS_FOR_JOINED_SUBCLASS
enableImplicitForcingOfDiscriminatorsInSelectback to summary
public MetadataBuilder enableImplicitForcingOfDiscriminatorsInSelect(boolean supported)

For entities which do not explicitly say, should we force discriminators into SQL selects? The (historical) default is false

Its default is defined by the org.hibernate.cfg.AvailableSettings#FORCE_DISCRIMINATOR_IN_SELECTS_BY_DEFAULT setting if using property-based configuration.

Parameters
supported:boolean

true indicates we will force the discriminator into the select; false indicates we will not.

Returns:MetadataBuilder

this, for method chaining

See Also
org.hibernate.cfg.AvailableSettings#FORCE_DISCRIMINATOR_IN_SELECTS_BY_DEFAULT
enableNewIdentifierGeneratorSupportback to summary
public MetadataBuilder enableNewIdentifierGeneratorSupport(boolean enable)

Should we enable support for the "new" (since 3.2) identifier generator mappings for handling:

Its default is defined by the org.hibernate.cfg.AvailableSettings#USE_NEW_ID_GENERATOR_MAPPINGS setting if using property-based configuration.

Parameters
enable:boolean

true to enable; false to disable; don't call for default.

Returns:MetadataBuilder

this, for method chaining

See Also
org.hibernate.cfg.AvailableSettings#USE_NEW_ID_GENERATOR_MAPPINGS
unwrapback to summary
public <T extends MetadataBuilder> T unwrap(Class<T> type)

Allows unwrapping this builder as another, more specific type.

Returns:T

The unwrapped builder.