Package org.hibernate.type.spi
Class TypeConfiguration
- java.lang.Object
-
- org.hibernate.type.spi.TypeConfiguration
-
- All Implemented Interfaces:
Serializable
,SessionFactoryObserver
public class TypeConfiguration extends Object implements SessionFactoryObserver, Serializable
Each instance defines a set of types available in a given persistence unit, and isolates them from other configurations.Note that each instance of
Type
is inherently "scoped" to aTypeConfiguration
. We always obtain a reference to aType
via theTypeConfiguration
associated with the current persistence unit.On the other hand, a
Type
does not inherently have access to its parentTypeConfiguration
since extensions may contribute instances ofType
, viaTypeContributions
, for example, and the instantiation of such instances occurs outside the control of Hibernate.In particular, a custom
TypeContributor
may contribute types to aTypeConfiguration
.If a
Type
requires access to the parentTypeConfiguration
, it should implementTypeConfigurationAware
.- Since:
- 5.3
- See Also:
TypeContributor
,TypeContributions
, Serialized Form
-
-
Constructor Summary
Constructors Constructor Description TypeConfiguration()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addBasicTypeRegistrationContributions(List<BasicTypeRegistration> contributions)
<J> MutabilityPlan<J>
createMutabilityPlan(Class<? extends MutabilityPlan<?>> planClass)
Class<?>
entityClassForEntityName(String entityName)
Workaround for an issue faced inEntityType.getReturnedClass()
.<J> BasicType<J>
getBasicTypeForGenericJavaType(Class<? super J> javaType, Type... typeArguments)
<J> BasicType<J>
getBasicTypeForJavaType(Class<J> javaType)
<J> BasicType<J>
getBasicTypeForJavaType(Type javaType)
BasicTypeRegistry
getBasicTypeRegistry()
JdbcTypeIndicators
getCurrentBaseSqlTypeIndicators()
DdlTypeRegistry
getDdlTypeRegistry()
JavaTypeRegistry
getJavaTypeRegistry()
Map<Integer,Set<String>>
getJdbcToHibernateTypeContributionMap()
JdbcTypeRegistry
getJdbcTypeRegistry()
JpaCompliance
getJpaCompliance()
Obtain theJpaCompliance
setting.MetadataBuildingContext
getMetadataBuildingContext()
Deprecated.This operation is not very typesafe, and we're migrating away from its useServiceRegistry
getServiceRegistry()
Deprecated.This simply isn't a very sensible place to hang theServiceRegistry
SessionFactoryImplementor
getSessionFactory()
Deprecated.This operation is not very typesafe, and we're migrating away from its useprotected static IntervalType
getSqlIntervalType(int jdbcTypeCode)
static IntervalType
getSqlIntervalType(JdbcMappingContainer jdbcMappings)
static IntervalType
getSqlIntervalType(JdbcType descriptor)
protected static jakarta.persistence.TemporalType
getSqlTemporalType(int jdbcTypeCode)
static jakarta.persistence.TemporalType
getSqlTemporalType(JdbcMapping jdbcMapping)
static jakarta.persistence.TemporalType
getSqlTemporalType(JdbcMappingContainer jdbcMappings)
static jakarta.persistence.TemporalType
getSqlTemporalType(MappingModelExpressible<?> type)
jakarta.persistence.TemporalType
getSqlTemporalType(SqmExpressible<?> type)
static jakarta.persistence.TemporalType
getSqlTemporalType(JdbcType descriptor)
String
getUuid()
static boolean
isDuration(SqmExpressible<?> type)
static boolean
isJdbcTemporalType(SqmExpressible<?> type)
SqmExpressible<?>
resolveArithmeticType(SqmExpressible<?> firstType, SqmExpressible<?> secondType)
Determine the result type of an arithmetic operation as defined by the rules in section 6.5.8.1.SqmExpressible<?>
resolveArithmeticType(SqmExpressible<?> firstType, SqmExpressible<?> secondType, BinaryArithmeticOperator operator)
BasicValuedMapping
resolveCastTargetType(String name)
Understands the following target type names for thecast()
function:String
Character
Byte
,Short
,Integer
,Long
Float
,Double
Time
,Date
,Timestamp
LocalDate
,LocalTime
,LocalDateTime
BigInteger
BigDecimal
Binary
Boolean
(fragile, not aware of encoding to character viaCharBooleanConverter
)SqmExpressible<?>
resolveTupleType(List<? extends SqmTypedNode<?>> typedNodes)
void
scope(MetadataBuildingContext metadataBuildingContext)
Scope thisTypeConfiguration
to the givenMetadataBuildingContext
.void
scope(SessionFactoryImplementor sessionFactory)
Scope thisTypeConfiguration
to the givenSessionFactory
.void
sessionFactoryClosed(SessionFactory factory)
Callback to indicate that the given factory has been closed.void
sessionFactoryCreated(SessionFactory factory)
Callback to indicate that the given factory has been created and is now ready for use.<J> BasicType<J>
standardBasicTypeForJavaType(Class<J> javaType)
<J> BasicType<J>
standardBasicTypeForJavaType(Class<J> javaType, Function<JavaType<J>,BasicType<J>> creator)
<J> BasicType<J>
standardBasicTypeForJavaType(Type javaType, Function<JavaType<J>,BasicType<J>> creator)
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.hibernate.SessionFactoryObserver
sessionFactoryClosing
-
-
-
-
Method Detail
-
getUuid
public String getUuid()
-
getBasicTypeRegistry
public BasicTypeRegistry getBasicTypeRegistry()
-
getJavaTypeRegistry
public JavaTypeRegistry getJavaTypeRegistry()
-
getJdbcTypeRegistry
public JdbcTypeRegistry getJdbcTypeRegistry()
-
getDdlTypeRegistry
public DdlTypeRegistry getDdlTypeRegistry()
-
getCurrentBaseSqlTypeIndicators
public JdbcTypeIndicators getCurrentBaseSqlTypeIndicators()
-
getJdbcToHibernateTypeContributionMap
public Map<Integer,Set<String>> getJdbcToHibernateTypeContributionMap()
-
getMetadataBuildingContext
@Deprecated(since="6.2") public MetadataBuildingContext getMetadataBuildingContext()
Deprecated.This operation is not very typesafe, and we're migrating away from its useObtain theMetadataBuildingContext
currently scoping thisTypeConfiguration
.- Returns:
- The
MetadataBuildingContext
-
scope
public void scope(MetadataBuildingContext metadataBuildingContext)
Scope thisTypeConfiguration
to the givenMetadataBuildingContext
.- Parameters:
metadataBuildingContext
- aMetadataBuildingContext
-
scope
public void scope(SessionFactoryImplementor sessionFactory)
Scope thisTypeConfiguration
to the givenSessionFactory
.- Parameters:
sessionFactory
- aSessionFactory
that is in a very fragile state
-
getSessionFactory
@Deprecated(since="6.2") public SessionFactoryImplementor getSessionFactory()
Deprecated.This operation is not very typesafe, and we're migrating away from its useObtain theSessionFactory
currently scoping thisTypeConfiguration
.- Returns:
- The
SessionFactory
to which thisTypeConfiguration
is scoped - Throws:
HibernateException
- if theTypeConfiguration
is not currently scoped to aSessionFactory
(in a "runtime stage").
-
getServiceRegistry
@Deprecated(since="6.2") public ServiceRegistry getServiceRegistry()
Deprecated.This simply isn't a very sensible place to hang theServiceRegistry
Obtain theServiceRegistry
scoped to thisTypeConfiguration
.- Returns:
- The
ServiceRegistry
for the current scope
-
getJpaCompliance
public JpaCompliance getJpaCompliance()
Obtain theJpaCompliance
setting.
-
entityClassForEntityName
public Class<?> entityClassForEntityName(String entityName)
Workaround for an issue faced inEntityType.getReturnedClass()
.
-
sessionFactoryCreated
public void sessionFactoryCreated(SessionFactory factory)
Description copied from interface:SessionFactoryObserver
Callback to indicate that the given factory has been created and is now ready for use.- Specified by:
sessionFactoryCreated
in interfaceSessionFactoryObserver
- Parameters:
factory
- The factory initialized.
-
sessionFactoryClosed
public void sessionFactoryClosed(SessionFactory factory)
Description copied from interface:SessionFactoryObserver
Callback to indicate that the given factory has been closed. Care should be taken in how (if at all) the passed factory reference is used since it is closed.- Specified by:
sessionFactoryClosed
in interfaceSessionFactoryObserver
- Parameters:
factory
- The factory closed.
-
addBasicTypeRegistrationContributions
public void addBasicTypeRegistrationContributions(List<BasicTypeRegistration> contributions)
-
resolveCastTargetType
public BasicValuedMapping resolveCastTargetType(String name)
Understands the following target type names for thecast()
function:String
Character
Byte
,Short
,Integer
,Long
Float
,Double
Time
,Date
,Timestamp
LocalDate
,LocalTime
,LocalDateTime
BigInteger
BigDecimal
Binary
Boolean
(fragile, not aware of encoding to character viaCharBooleanConverter
)
The type names are not case-sensitive.
-
resolveTupleType
public SqmExpressible<?> resolveTupleType(List<? extends SqmTypedNode<?>> typedNodes)
-
resolveArithmeticType
public SqmExpressible<?> resolveArithmeticType(SqmExpressible<?> firstType, SqmExpressible<?> secondType, BinaryArithmeticOperator operator)
-
resolveArithmeticType
public SqmExpressible<?> resolveArithmeticType(SqmExpressible<?> firstType, SqmExpressible<?> secondType)
Determine the result type of an arithmetic operation as defined by the rules in section 6.5.8.1.
-
getBasicTypeForGenericJavaType
public <J> BasicType<J> getBasicTypeForGenericJavaType(Class<? super J> javaType, Type... typeArguments)
-
standardBasicTypeForJavaType
public <J> BasicType<J> standardBasicTypeForJavaType(Class<J> javaType)
-
standardBasicTypeForJavaType
public <J> BasicType<J> standardBasicTypeForJavaType(Class<J> javaType, Function<JavaType<J>,BasicType<J>> creator)
-
standardBasicTypeForJavaType
public <J> BasicType<J> standardBasicTypeForJavaType(Type javaType, Function<JavaType<J>,BasicType<J>> creator)
-
getSqlTemporalType
public jakarta.persistence.TemporalType getSqlTemporalType(SqmExpressible<?> type)
-
getSqlTemporalType
public static jakarta.persistence.TemporalType getSqlTemporalType(JdbcMapping jdbcMapping)
-
getSqlTemporalType
public static jakarta.persistence.TemporalType getSqlTemporalType(JdbcMappingContainer jdbcMappings)
-
getSqlTemporalType
public static jakarta.persistence.TemporalType getSqlTemporalType(MappingModelExpressible<?> type)
-
getSqlTemporalType
public static jakarta.persistence.TemporalType getSqlTemporalType(JdbcType descriptor)
-
getSqlTemporalType
protected static jakarta.persistence.TemporalType getSqlTemporalType(int jdbcTypeCode)
-
getSqlIntervalType
public static IntervalType getSqlIntervalType(JdbcMappingContainer jdbcMappings)
-
getSqlIntervalType
public static IntervalType getSqlIntervalType(JdbcType descriptor)
-
getSqlIntervalType
protected static IntervalType getSqlIntervalType(int jdbcTypeCode)
-
isJdbcTemporalType
public static boolean isJdbcTemporalType(SqmExpressible<?> type)
-
isDuration
public static boolean isDuration(SqmExpressible<?> type)
-
createMutabilityPlan
public <J> MutabilityPlan<J> createMutabilityPlan(Class<? extends MutabilityPlan<?>> planClass)
-
-