Top Description Methods
org.hibernate.boot

public Interface MetadataBuilder

Known Direct Subinterfaces
org.hibernate.boot.spi.MetadataBuilderImplementor
Imports
org.hibernate.boot.archive.scan.spi.ScanEnvironment, .ScanOptions, .Scanner, org.hibernate.boot.archive.spi.ArchiveDescriptorFactory, org.hibernate.boot.model.FunctionContributor, .TypeContributor, org.hibernate.boot.model.convert.spi.ConverterDescriptor, org.hibernate.boot.model.naming.ImplicitNamingStrategy, .PhysicalNamingStrategy, org.hibernate.boot.model.relational.AuxiliaryDatabaseObject, .ColumnOrderingStrategy, org.hibernate.cache.spi.access.AccessType, org.hibernate.cfg.MetadataSourceType, org.hibernate.metamodel.CollectionClassification, org.hibernate.query.sqm.function.SqmFunctionDescriptor, org.hibernate.type.BasicType, org.hibernate.usertype.UserType, org.jboss.jandex.IndexView, jakarta.persistence.AttributeConverter, .SharedCacheMode

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
(ConverterDescriptor
The descriptor
descriptor
)

Adds an AttributeConverter by a ConverterDescriptor

public <O, R> MetadataBuilder

Returns:

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

Adds an AttributeConverter by its Class.

public <O, R> MetadataBuilder

Returns:

this for method chaining
applyAttributeConverter
(Class<? extends AttributeConverter<O, R>>
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 Class, explicitly indicating whether to auto-apply it.

public <O, R> MetadataBuilder

Returns:

this for method chaining
applyAttributeConverter
(AttributeConverter<O, R>
The AttributeConverter instance.
attributeConverter
)

Adds an AttributeConverter instance.

public MetadataBuilder

Returns:

this for method chaining
applyAttributeConverter
(AttributeConverter<?, ?>
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 it.

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
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

Returns:

this, for method chaining
applyColumnOrderingStrategy
(ColumnOrderingStrategy columnOrderingStrategy)

Specify the ColumnOrderingStrategy.

public MetadataBuilder

Returns:

this, for method chaining
applyFunctions
(FunctionContributor
The contributor to apply
functionContributor
)

Apply an explicit FunctionContributor (implicit application via java.util.ServiceLoader will still happen too)

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
public MetadataBuilder

Returns:

this, for method chaining
applyImplicitNamingStrategy
(ImplicitNamingStrategy namingStrategy)

Specify the ImplicitNamingStrategy.

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 namingStrategy)

Specify the PhysicalNamingStrategy.

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.

public MetadataBuilder

Returns:

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

Deprecated for removal since 6. hbm.xml mappings are no longer supported, making this irrelevant
Apply a specific ordering to the processing of sources.
public MetadataBuilder
applySqlFunction(String functionName, SqmFunctionDescriptor function)

Contribute a SqmFunctionDescriptor to HQL.

public MetadataBuilder

Returns:

this, for method chaining
applyTempClassLoader
(ClassLoader
ClassLoader for use while 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 java.util.ServiceLoader will still happen too)

public Metadata

Returns:

The built metadata.
build
()

Deprecated as a consequence of Metadata being deprecated.
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?

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 hibernate.cache.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(jakarta.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 hibernate.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(ConverterDescriptor descriptor)

Adds an AttributeConverter by a ConverterDescriptor

Parameters
descriptor:ConverterDescriptor

The descriptor

Returns:MetadataBuilder

this for method chaining

applyAttributeConverterback to summary
public <O, R> MetadataBuilder applyAttributeConverter(Class<? extends AttributeConverter<O, R>> attributeConverterClass)

Adds an AttributeConverter by its Class.

Parameters
attributeConverterClass:Class<? extends AttributeConverter<O, R>>

The AttributeConverter class.

Returns:MetadataBuilder

this for method chaining

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

Adds an AttributeConverter by Class, explicitly indicating whether to auto-apply it.

Parameters
attributeConverterClass:Class<? extends AttributeConverter<O, R>>

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

applyAttributeConverterback to summary
public <O, R> MetadataBuilder applyAttributeConverter(AttributeConverter<O, R> attributeConverter)

Adds an AttributeConverter instance.

Parameters
attributeConverter:AttributeConverter<O, R>

The AttributeConverter instance.

Returns:MetadataBuilder

this for method chaining

applyAttributeConverterback to summary
public MetadataBuilder applyAttributeConverter(AttributeConverter<?, ?> attributeConverter, boolean autoApply)

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

Parameters
attributeConverter:AttributeConverter<?, ?>

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

applyAuxiliaryDatabaseObjectback to summary
public MetadataBuilder applyAuxiliaryDatabaseObject(AuxiliaryDatabaseObject auxiliaryDatabaseObject)

Contribute an 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

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

applyColumnOrderingStrategyback to summary
public MetadataBuilder applyColumnOrderingStrategy(ColumnOrderingStrategy columnOrderingStrategy)

Specify the ColumnOrderingStrategy.

Its default is defined by the hibernate.column_ordering_strategy setting if using property-based configuration.

Parameters
columnOrderingStrategy:ColumnOrderingStrategy

The ColumnOrderingStrategy

Returns:MetadataBuilder

this, for method chaining

See Also
org.hibernate.cfg.AvailableSettings#IMPLICIT_NAMING_STRATEGY
applyFunctionsback to summary
public MetadataBuilder applyFunctions(FunctionContributor functionContributor)

Apply an explicit FunctionContributor (implicit application via java.util.ServiceLoader will still happen too)

Parameters
functionContributor:FunctionContributor

The contributor to apply

Returns:MetadataBuilder

this, for method chaining

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 hibernate.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
applyImplicitListSemanticsback to summary
public MetadataBuilder applyImplicitListSemantics(CollectionClassification classification)
applyImplicitNamingStrategyback to summary
public MetadataBuilder applyImplicitNamingStrategy(ImplicitNamingStrategy namingStrategy)

Specify the ImplicitNamingStrategy.

Its default is defined by the hibernate.implicit_naming_strategy setting if using property-based configuration.

Parameters
namingStrategy:ImplicitNamingStrategy

The ImplicitNamingStrategy

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 hibernate.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's 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.

API 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.

Its default is defined by the hibernate.physical_naming_strategy setting if using property-based configuration.

Parameters
namingStrategy:PhysicalNamingStrategy

The PhysicalNamingStrategy

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 hibernate.archive.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.

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)

Deprecated

for removal since 6.

hbm.xml mappings are no longer supported, making this irrelevant

Apply a specific ordering to the processing of sources.

Unlike most of the methods of this interface (which deal with multiple values internally), this one replaces any source processing order that was already set.

Its default is defined by the hibernate.mapping.precedence setting if using property-based configuration.

Parameters
sourceTypes:MetadataSourceType[]

The types, in the order they should be processed

Returns:MetadataBuilder

this for method chaining

Annotations
@Deprecated
since:6
forRemoval:true
See Also
org.hibernate.cfg.AvailableSettings#ARTIFACT_PROCESSING_ORDER
applySqlFunctionback to summary
public MetadataBuilder applySqlFunction(String functionName, SqmFunctionDescriptor function)

Contribute a SqmFunctionDescriptor to HQL.

See Also
org.hibernate.dialect.function.StandardSQLFunction
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 where we absolutely must.

In EE managed environments, this is the ClassLoader mandated by jakarta.persistence.spi.PersistenceUnitInfo#getNewTempClassLoader(). This ClassLoader is discarded by the container afterward, 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 while building the Metadata

Returns:MetadataBuilder

this, for method chaining

applyTypesback to summary
public MetadataBuilder applyTypes(TypeContributor typeContributor)

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

Parameters
typeContributor:TypeContributor

The contributor to apply

Returns:MetadataBuilder

this, for method chaining

buildback to summary
public Metadata build()

Deprecated

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

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 hibernate.discriminator.ignore_explicit_for_joined 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 hibernate.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 hibernate.discriminator.implicit_for_joined 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 hibernate.discriminator.force_in_select 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