Package org.hibernate.boot.internal
Class MetadataBuilderImpl
- java.lang.Object
-
- org.hibernate.boot.internal.MetadataBuilderImpl
-
- All Implemented Interfaces:
MetadataBuilder,TypeContributions,MetadataBuilderImplementor
public class MetadataBuilderImpl extends Object implements MetadataBuilderImplementor, TypeContributions
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classMetadataBuilderImpl.MappingDefaultsImplstatic classMetadataBuilderImpl.MetadataBuildingOptionsImpl
-
Constructor Summary
Constructors Constructor Description MetadataBuilderImpl(MetadataSources sources)MetadataBuilderImpl(MetadataSources sources, StandardServiceRegistry serviceRegistry)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description MetadataBuilderallowSpecjSyntax()MetadataBuilderapplyAccessType(AccessType implicitCacheAccessType)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.MetadataBuilderapplyArchiveDescriptorFactory(ArchiveDescriptorFactory factory)Specify a particular ArchiveDescriptorFactory instance to use in scanning.MetadataBuilderapplyAttributeConverter(jakarta.persistence.AttributeConverter<?,?> attributeConverter, boolean autoApply)Adds an AttributeConverter instance, explicitly indicating whether to auto-apply.<O,R>
MetadataBuilderapplyAttributeConverter(jakarta.persistence.AttributeConverter<O,R> attributeConverter)Adds an AttributeConverter instance.<O,R>
MetadataBuilderapplyAttributeConverter(Class<? extends jakarta.persistence.AttributeConverter<O,R>> attributeConverterClass)Adds an AttributeConverter by its Class.<O,R>
MetadataBuilderapplyAttributeConverter(Class<? extends jakarta.persistence.AttributeConverter<O,R>> attributeConverterClass, boolean autoApply)Adds an AttributeConverter by its Class plus a boolean indicating whether to auto apply it.MetadataBuilderapplyAttributeConverter(ConverterDescriptor descriptor)Adds an AttributeConverter by aConverterDescriptorMetadataBuilderapplyAuxiliaryDatabaseObject(AuxiliaryDatabaseObject auxiliaryDatabaseObject)MetadataBuilderapplyBasicType(BasicType<?> type)Specify an additional or overridden basic type mapping.MetadataBuilderapplyBasicType(BasicType<?> type, String... keys)Specify an additional or overridden basic type mapping supplying specific registration keys.MetadataBuilderapplyBasicType(UserType<?> type, String... keys)Register an additional or overridden custom type mapping.MetadataBuilderapplyCacheRegionDefinition(CacheRegionDefinition cacheRegionDefinition)Apply a CacheRegionDefinition to be applied to an entity, collection or query while building the Metadata object.MetadataBuilderapplyIdGenerationTypeInterpreter(IdGeneratorStrategyInterpreter interpreter)MetadataBuilderapplyImplicitCatalogName(String implicitCatalogName)Specify the implicit catalog name to apply to any unqualified database names.MetadataBuilderapplyImplicitListSemantics(CollectionClassification classification)MetadataBuilderapplyImplicitNamingStrategy(ImplicitNamingStrategy namingStrategy)Specify the ImplicitNamingStrategy to use in building the Metadata.MetadataBuilderapplyImplicitSchemaName(String implicitSchemaName)Specify the implicit schema name to apply to any unqualified database names.MetadataBuilderapplyIndexView(org.jboss.jandex.IndexView jandexView)Allows specifying a specific Jandex index to use for reading annotation information.MetadataBuilderapplyPhysicalNamingStrategy(PhysicalNamingStrategy namingStrategy)Specify the PhysicalNamingStrategy to use in building the Metadata.MetadataBuilderapplyScanEnvironment(ScanEnvironment scanEnvironment)Consider this temporary as discussed onScanEnvironmentMetadataBuilderapplyScanner(Scanner scanner)Specify a particular Scanner instance to use.MetadataBuilderapplyScanOptions(ScanOptions scanOptions)Specify the options to be used in performing scanning.MetadataBuilderapplySharedCacheMode(jakarta.persistence.SharedCacheMode sharedCacheMode)Specify the second-level cache mode to be used.MetadataBuilderapplySourceProcessOrdering(MetadataSourceType... sourceTypes)Apply a specific ordering to the processing of sources.MetadataBuilderapplySqlFunction(String functionName, SqmFunctionDescriptor function)MetadataBuilderapplyTempClassLoader(ClassLoader tempClassLoader)Apply a ClassLoader for use while building the Metadata.MetadataBuilderapplyTypes(TypeContributor typeContributor)Apply an explicit TypeContributor (implicit application via ServiceLoader will still happen too)MetadataImplementorbuild()Actually build the metamodelvoidcontributeType(BasicType<?> type)voidcontributeType(BasicType<?> type, String... keys)voidcontributeType(UserType<?> type, String[] keys)MetadataBuilderenableExplicitDiscriminatorsForJoinedSubclassSupport(boolean supported)Should we process or ignore explicitly defined discriminators in the case of joined-subclasses.MetadataBuilderenableGlobalNationalizedCharacterDataSupport(boolean enabled)Should nationalized variants of character data be used in the database types? For example, shouldNVARCHARbe used instead ofVARCHAR?NCLOBinstead ofCLOB?MetadataBuilderenableImplicitDiscriminatorsForJoinedSubclassSupport(boolean supported)Similarly toMetadataBuilder.enableExplicitDiscriminatorsForJoinedSubclassSupport(boolean), 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).MetadataBuilderenableImplicitForcingOfDiscriminatorsInSelect(boolean supported)For entities which do not explicitly say, should we force discriminators into SQL selects? The (historical) default isfalseBootstrapContextgetBootstrapContext()MetadataBuildingOptionsgetMetadataBuildingOptions()Get the options being collected on this MetadataBuilder that will ultimately be used in building the Metadata.TypeConfigurationgetTypeConfiguration()MetadataBuildernoConstraintByDefault()-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.hibernate.boot.model.TypeContributions
contributeJavaType, contributeJdbcType, contributeType
-
-
-
-
Constructor Detail
-
MetadataBuilderImpl
public MetadataBuilderImpl(MetadataSources sources)
-
MetadataBuilderImpl
public MetadataBuilderImpl(MetadataSources sources, StandardServiceRegistry serviceRegistry)
-
-
Method Detail
-
applyImplicitSchemaName
public MetadataBuilder applyImplicitSchemaName(String implicitSchemaName)
Description copied from interface:MetadataBuilderSpecify 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.- Specified by:
applyImplicitSchemaNamein interfaceMetadataBuilder- Parameters:
implicitSchemaName- The implicit schema name- Returns:
this, for method chaining- See Also:
AvailableSettings.DEFAULT_SCHEMA
-
applyImplicitCatalogName
public MetadataBuilder applyImplicitCatalogName(String implicitCatalogName)
Description copied from interface:MetadataBuilderSpecify 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.- Specified by:
applyImplicitCatalogNamein interfaceMetadataBuilder- Parameters:
implicitCatalogName- The implicit catalog name- Returns:
this, for method chaining- See Also:
AvailableSettings.DEFAULT_CATALOG
-
applyImplicitNamingStrategy
public MetadataBuilder applyImplicitNamingStrategy(ImplicitNamingStrategy namingStrategy)
Description copied from interface:MetadataBuilderSpecify the ImplicitNamingStrategy to use in building the Metadata. Its default is defined by the "hibernate.implicit_naming_strategy" setting if using property-based configuration.- Specified by:
applyImplicitNamingStrategyin interfaceMetadataBuilder- Parameters:
namingStrategy- The ImplicitNamingStrategy to apply- Returns:
this, for method chaining- See Also:
AvailableSettings.IMPLICIT_NAMING_STRATEGY
-
applyPhysicalNamingStrategy
public MetadataBuilder applyPhysicalNamingStrategy(PhysicalNamingStrategy namingStrategy)
Description copied from interface:MetadataBuilderSpecify the PhysicalNamingStrategy to use in building the Metadata. Its default is defined by the "hibernate.physical_naming_strategy" setting if using property-based configuration.- Specified by:
applyPhysicalNamingStrategyin interfaceMetadataBuilder- Parameters:
namingStrategy- The PhysicalNamingStrategy to apply- Returns:
this, for method chaining- See Also:
AvailableSettings.PHYSICAL_NAMING_STRATEGY
-
applySharedCacheMode
public MetadataBuilder applySharedCacheMode(jakarta.persistence.SharedCacheMode sharedCacheMode)
Description copied from interface:MetadataBuilderSpecify 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 thejavax.persistence.sharedCache.modesetting if using property-based configuration.- Specified by:
applySharedCacheModein interfaceMetadataBuilder- Parameters:
sharedCacheMode- The cache mode.- Returns:
this, for method chaining- See Also:
MetadataBuilder.applyAccessType(org.hibernate.cache.spi.access.AccessType)
-
applyAccessType
public MetadataBuilder applyAccessType(AccessType implicitCacheAccessType)
Description copied from interface:MetadataBuilderSpecify 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.- Specified by:
applyAccessTypein interfaceMetadataBuilder- Parameters:
implicitCacheAccessType- The access-type to use as default.- Returns:
this, for method chaining- See Also:
AvailableSettings.DEFAULT_CACHE_CONCURRENCY_STRATEGY,MetadataBuilder.applySharedCacheMode(jakarta.persistence.SharedCacheMode)
-
applyIndexView
public MetadataBuilder applyIndexView(org.jboss.jandex.IndexView jandexView)
Description copied from interface:MetadataBuilderAllows 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.- Specified by:
applyIndexViewin interfaceMetadataBuilder- Parameters:
jandexView- The Jandex index to use.- Returns:
this, for method chaining
-
applyScanOptions
public MetadataBuilder applyScanOptions(ScanOptions scanOptions)
Description copied from interface:MetadataBuilderSpecify the options to be used in performing scanning.- Specified by:
applyScanOptionsin interfaceMetadataBuilder- Parameters:
scanOptions- The scan options.- Returns:
this, for method chaining- See Also:
AvailableSettings.SCANNER_DISCOVERY
-
applyScanEnvironment
public MetadataBuilder applyScanEnvironment(ScanEnvironment scanEnvironment)
Description copied from interface:MetadataBuilderConsider this temporary as discussed onScanEnvironment- Specified by:
applyScanEnvironmentin interfaceMetadataBuilder- Parameters:
scanEnvironment- The environment for scanning- Returns:
this, for method chaining
-
applyScanner
public MetadataBuilder applyScanner(Scanner scanner)
Description copied from interface:MetadataBuilderSpecify a particular Scanner instance to use. Its default is defined by the "hibernate.archive.scanner" setting if using property-based configuration.- Specified by:
applyScannerin interfaceMetadataBuilder- Parameters:
scanner- The scanner to use.- Returns:
this, for method chaining- See Also:
AvailableSettings.SCANNER
-
applyArchiveDescriptorFactory
public MetadataBuilder applyArchiveDescriptorFactory(ArchiveDescriptorFactory factory)
Description copied from interface:MetadataBuilderSpecify a particular ArchiveDescriptorFactory instance to use in scanning. Its default is defined by the "hibernate.archive.interpreter" setting if using property-based configuration.- Specified by:
applyArchiveDescriptorFactoryin interfaceMetadataBuilder- Parameters:
factory- The ArchiveDescriptorFactory to use.- Returns:
this, for method chaining- See Also:
AvailableSettings.SCANNER_ARCHIVE_INTERPRETER
-
applyImplicitListSemantics
public MetadataBuilder applyImplicitListSemantics(CollectionClassification classification)
- Specified by:
applyImplicitListSemanticsin interfaceMetadataBuilder
-
enableExplicitDiscriminatorsForJoinedSubclassSupport
public MetadataBuilder enableExplicitDiscriminatorsForJoinedSubclassSupport(boolean supported)
Description copied from interface:MetadataBuilderShould 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.- Specified by:
enableExplicitDiscriminatorsForJoinedSubclassSupportin interfaceMetadataBuilder- Parameters:
supported- Should processing (not ignoring) explicit discriminators be enabled?- Returns:
this, for method chaining- See Also:
AvailableSettings.IGNORE_EXPLICIT_DISCRIMINATOR_COLUMNS_FOR_JOINED_SUBCLASS
-
enableImplicitDiscriminatorsForJoinedSubclassSupport
public MetadataBuilder enableImplicitDiscriminatorsForJoinedSubclassSupport(boolean supported)
Description copied from interface:MetadataBuilderSimilarly toMetadataBuilder.enableExplicitDiscriminatorsForJoinedSubclassSupport(boolean), 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.- Specified by:
enableImplicitDiscriminatorsForJoinedSubclassSupportin interfaceMetadataBuilder- Parameters:
supported- Should we implicitly create discriminator for joined inheritance if one is not explicitly mentioned?- Returns:
this, for method chaining- See Also:
AvailableSettings.IMPLICIT_DISCRIMINATOR_COLUMNS_FOR_JOINED_SUBCLASS
-
enableImplicitForcingOfDiscriminatorsInSelect
public MetadataBuilder enableImplicitForcingOfDiscriminatorsInSelect(boolean supported)
Description copied from interface:MetadataBuilderFor entities which do not explicitly say, should we force discriminators into SQL selects? The (historical) default isfalseIts default is defined by the "hibernate.discriminator.force_in_select" setting if using property-based configuration.- Specified by:
enableImplicitForcingOfDiscriminatorsInSelectin interfaceMetadataBuilder- Parameters:
supported-trueindicates we will force the discriminator into the select;falseindicates we will not.- Returns:
this, for method chaining- See Also:
AvailableSettings.FORCE_DISCRIMINATOR_IN_SELECTS_BY_DEFAULT
-
enableGlobalNationalizedCharacterDataSupport
public MetadataBuilder enableGlobalNationalizedCharacterDataSupport(boolean enabled)
Description copied from interface:MetadataBuilderShould nationalized variants of character data be used in the database types? For example, shouldNVARCHARbe used instead ofVARCHAR?NCLOBinstead ofCLOB? Its default is defined by the "hibernate.use_nationalized_character_data" setting if using property-based configuration.- Specified by:
enableGlobalNationalizedCharacterDataSupportin interfaceMetadataBuilder- Parameters:
enabled-truesays to use nationalized variants;falsesays to use the non-nationalized variants.- Returns:
this, for method chaining- See Also:
AvailableSettings.USE_NATIONALIZED_CHARACTER_DATA
-
applyBasicType
public MetadataBuilder applyBasicType(BasicType<?> type)
Description copied from interface:MetadataBuilderSpecify an additional or overridden basic type mapping.- Specified by:
applyBasicTypein interfaceMetadataBuilder- Parameters:
type- The type addition or override.- Returns:
this, for method chaining
-
applyBasicType
public MetadataBuilder applyBasicType(BasicType<?> type, String... keys)
Description copied from interface:MetadataBuilderSpecify an additional or overridden basic type mapping supplying specific registration keys.- Specified by:
applyBasicTypein interfaceMetadataBuilder- Parameters:
type- The type addition or override.keys- The keys under which to register the basic type.- Returns:
this, for method chaining
-
applyBasicType
public MetadataBuilder applyBasicType(UserType<?> type, String... keys)
Description copied from interface:MetadataBuilderRegister an additional or overridden custom type mapping.- Specified by:
applyBasicTypein interfaceMetadataBuilder- Parameters:
type- The custom typekeys- The keys under which to register the custom type.- Returns:
this, for method chaining
-
applyTypes
public MetadataBuilder applyTypes(TypeContributor typeContributor)
Description copied from interface:MetadataBuilderApply an explicit TypeContributor (implicit application via ServiceLoader will still happen too)- Specified by:
applyTypesin interfaceMetadataBuilder- Parameters:
typeContributor- The contributor to apply- Returns:
this, for method chaining
-
contributeType
public void contributeType(BasicType<?> type)
- Specified by:
contributeTypein interfaceTypeContributions
-
contributeType
public void contributeType(BasicType<?> type, String... keys)
- Specified by:
contributeTypein interfaceTypeContributions
-
contributeType
public void contributeType(UserType<?> type, String[] keys)
- Specified by:
contributeTypein interfaceTypeContributions
-
getTypeConfiguration
public TypeConfiguration getTypeConfiguration()
- Specified by:
getTypeConfigurationin interfaceTypeContributions
-
applyCacheRegionDefinition
public MetadataBuilder applyCacheRegionDefinition(CacheRegionDefinition cacheRegionDefinition)
Description copied from interface:MetadataBuilderApply a CacheRegionDefinition to be applied to an entity, collection or query while building the Metadata object.- Specified by:
applyCacheRegionDefinitionin interfaceMetadataBuilder- Parameters:
cacheRegionDefinition- The cache region definition to apply- Returns:
this, for method chaining
-
applyTempClassLoader
public MetadataBuilder applyTempClassLoader(ClassLoader tempClassLoader)
Description copied from interface:MetadataBuilderApply 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 byPersistenceUnitInfo.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.- Specified by:
applyTempClassLoaderin interfaceMetadataBuilder- Parameters:
tempClassLoader- ClassLoader for use during building the Metadata- Returns:
this, for method chaining
-
applySourceProcessOrdering
public MetadataBuilder applySourceProcessOrdering(MetadataSourceType... sourceTypes)
Description copied from interface:MetadataBuilderApply 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 "hibernate.mapping.precedence" setting if using property-based configuration.- Specified by:
applySourceProcessOrderingin interfaceMetadataBuilder- Parameters:
sourceTypes- The types, in the order they should be processed- Returns:
thisfor method chaining- See Also:
AvailableSettings.ARTIFACT_PROCESSING_ORDER
-
allowSpecjSyntax
public MetadataBuilder allowSpecjSyntax()
-
noConstraintByDefault
public MetadataBuilder noConstraintByDefault()
-
applySqlFunction
public MetadataBuilder applySqlFunction(String functionName, SqmFunctionDescriptor function)
- Specified by:
applySqlFunctionin interfaceMetadataBuilder
-
applyAuxiliaryDatabaseObject
public MetadataBuilder applyAuxiliaryDatabaseObject(AuxiliaryDatabaseObject auxiliaryDatabaseObject)
- Specified by:
applyAuxiliaryDatabaseObjectin interfaceMetadataBuilder
-
applyAttributeConverter
public MetadataBuilder applyAttributeConverter(ConverterDescriptor descriptor)
Description copied from interface:MetadataBuilderAdds an AttributeConverter by aConverterDescriptor- Specified by:
applyAttributeConverterin interfaceMetadataBuilder- Parameters:
descriptor- The descriptor- Returns:
thisfor method chaining
-
applyAttributeConverter
public <O,R> MetadataBuilder applyAttributeConverter(Class<? extends jakarta.persistence.AttributeConverter<O,R>> attributeConverterClass)
Description copied from interface:MetadataBuilderAdds an AttributeConverter by its Class.- Specified by:
applyAttributeConverterin interfaceMetadataBuilder- Parameters:
attributeConverterClass- The AttributeConverter class.- Returns:
thisfor method chaining
-
applyAttributeConverter
public <O,R> MetadataBuilder applyAttributeConverter(Class<? extends jakarta.persistence.AttributeConverter<O,R>> attributeConverterClass, boolean autoApply)
Description copied from interface:MetadataBuilderAdds an AttributeConverter by its Class plus a boolean indicating whether to auto apply it.- Specified by:
applyAttributeConverterin interfaceMetadataBuilder- Parameters:
attributeConverterClass- The AttributeConverter class.autoApply- Should the AttributeConverter be auto applied to property types as specified by its "entity attribute" parameterized type?- Returns:
thisfor method chaining
-
applyAttributeConverter
public <O,R> MetadataBuilder applyAttributeConverter(jakarta.persistence.AttributeConverter<O,R> attributeConverter)
Description copied from interface:MetadataBuilderAdds an AttributeConverter instance.- Specified by:
applyAttributeConverterin interfaceMetadataBuilder- Parameters:
attributeConverter- The AttributeConverter instance.- Returns:
thisfor method chaining
-
applyAttributeConverter
public MetadataBuilder applyAttributeConverter(jakarta.persistence.AttributeConverter<?,?> attributeConverter, boolean autoApply)
Description copied from interface:MetadataBuilderAdds an AttributeConverter instance, explicitly indicating whether to auto-apply.- Specified by:
applyAttributeConverterin interfaceMetadataBuilder- Parameters:
attributeConverter- The AttributeConverter instance.autoApply- Should the AttributeConverter be auto applied to property types as specified by its "entity attribute" parameterized type?- Returns:
thisfor method chaining
-
applyIdGenerationTypeInterpreter
public MetadataBuilder applyIdGenerationTypeInterpreter(IdGeneratorStrategyInterpreter interpreter)
- Specified by:
applyIdGenerationTypeInterpreterin interfaceMetadataBuilder
-
build
public MetadataImplementor build()
Description copied from interface:MetadataBuilderActually build the metamodel- Specified by:
buildin interfaceMetadataBuilder- Returns:
- The built metadata.
-
getBootstrapContext
public BootstrapContext getBootstrapContext()
- Specified by:
getBootstrapContextin interfaceMetadataBuilderImplementor
-
getMetadataBuildingOptions
public MetadataBuildingOptions getMetadataBuildingOptions()
Description copied from interface:MetadataBuilderImplementorGet the options being collected on this MetadataBuilder that will ultimately be used in building the Metadata.- Specified by:
getMetadataBuildingOptionsin interfaceMetadataBuilderImplementor- Returns:
- The current building options
-
-