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
Defines a set of available Type instances as isolated from other configurations. The isolation is defined by each instance of a TypeConfiguration. Note that each Type is inherently "scoped" to a TypeConfiguration. We only ever access a Type through a TypeConfiguration - specifically the TypeConfiguration in effect for the current persistence unit. Even though each Type instance is scoped to a TypeConfiguration, Types do not inherently have access to that TypeConfiguration (mainly because Type is an extension contract - meaning that Hibernate does not manage the full set of Types available in ever TypeConfiguration). However Types will often want access to the TypeConfiguration, which can be achieved by the Type simply implementing theTypeConfigurationAwareinterface.- Since:
- 5.3
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description TypeConfiguration()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddBasicTypeRegistrationContributions(List<BasicTypeRegistration> contributions)<J> BasicType<J>getBasicTypeForGenericJavaType(Class<? super J> javaType, Type... typeArguments)<J> BasicType<J>getBasicTypeForJavaType(Class<J> javaType)<J> BasicType<J>getBasicTypeForJavaType(Type javaType)BasicTypeRegistrygetBasicTypeRegistry()JdbcTypeIndicatorsgetCurrentBaseSqlTypeIndicators()DdlTypeRegistrygetDdlTypeRegistry()JavaTypeRegistrygetJavaTypeRegistry()Map<Integer,Set<String>>getJdbcToHibernateTypeContributionMap()JdbcTypeRegistrygetJdbcTypeRegistry()MetadataBuildingContextgetMetadataBuildingContext()Obtain the MetadataBuildingContext currently scoping the TypeConfiguration.ServiceRegistrygetServiceRegistry()Obtain the ServiceRegistry scoped to the TypeConfiguration.SessionFactoryImplementorgetSessionFactory()Obtain the SessionFactory currently scoping the TypeConfiguration.protected static IntervalTypegetSqlIntervalType(int jdbcTypeCode)static IntervalTypegetSqlIntervalType(JdbcMappingContainer jdbcMappings)static IntervalTypegetSqlIntervalType(JdbcType descriptor)protected static TemporalTypegetSqlTemporalType(int jdbcTypeCode)static TemporalTypegetSqlTemporalType(JdbcMapping jdbcMapping)static TemporalTypegetSqlTemporalType(JdbcMappingContainer jdbcMappings)static TemporalTypegetSqlTemporalType(MappingModelExpressible<?> type)TemporalTypegetSqlTemporalType(SqmExpressible<?> type)static TemporalTypegetSqlTemporalType(JdbcType descriptor)StringgetUuid()static booleanisDuration(SqmExpressible<?> type)static booleanisJdbcTemporalType(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)BasicValuedMappingresolveCastTargetType(String name)Understands the following target type names for the cast() function: - String - Character - Byte, Integer, Long - Float, Double - Time, Date, Timestamp - LocalDate, LocalTime, LocalDateTime - BigInteger - BigDecimal - Binary - Boolean (fragile) (The type names are not case-sensitive.)SqmExpressible<?>resolveTupleType(List<? extends SqmTypedNode<?>> typedNodes)voidscope(MetadataBuildingContext metadataBuildingContext)org.hibernate.metamodel.model.domain.internal.MappingMetamodelImplscope(SessionFactoryImplementor sessionFactory)voidsessionFactoryClosed(SessionFactory factory)Callback to indicate that the given factory has been closed.voidsessionFactoryCreated(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
public MetadataBuildingContext getMetadataBuildingContext()
Obtain the MetadataBuildingContext currently scoping the TypeConfiguration.- Returns:
- The MetadataBuildingContext
- "API Note:"
- This will throw an exception if the SessionFactory is not yet
bound here. See
TypeConfiguration.Scopefor more details regarding the stages a TypeConfiguration goes through
-
scope
public void scope(MetadataBuildingContext metadataBuildingContext)
-
scope
public org.hibernate.metamodel.model.domain.internal.MappingMetamodelImpl scope(SessionFactoryImplementor sessionFactory)
-
getSessionFactory
public SessionFactoryImplementor getSessionFactory()
Obtain the SessionFactory currently scoping the TypeConfiguration.- Returns:
- The SessionFactory
- Throws:
IllegalStateException- if the TypeConfiguration is currently not associated with a SessionFactory (in "runtime stage").- "API Note:"
- This will throw an exception if the SessionFactory is not yet
bound here. See
TypeConfiguration.Scopefor more details regarding the stages a TypeConfiguration goes through (this is "runtime stage")
-
getServiceRegistry
public ServiceRegistry getServiceRegistry()
Obtain the ServiceRegistry scoped to the TypeConfiguration.- Returns:
- The ServiceRegistry
- "API Note:"
- Depending on what the
TypeConfiguration.Scopeis currently scoped to will determine where theServiceRegistryis obtained from.
-
sessionFactoryCreated
public void sessionFactoryCreated(SessionFactory factory)
Description copied from interface:SessionFactoryObserverCallback to indicate that the given factory has been created and is now ready for use.- Specified by:
sessionFactoryCreatedin interfaceSessionFactoryObserver- Parameters:
factory- The factory initialized.
-
sessionFactoryClosed
public void sessionFactoryClosed(SessionFactory factory)
Description copied from interface:SessionFactoryObserverCallback 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:
sessionFactoryClosedin 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 the cast() function: - String - Character - Byte, Integer, Long - Float, Double - Time, Date, Timestamp - LocalDate, LocalTime, LocalDateTime - BigInteger - BigDecimal - Binary - Boolean (fragile) (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)
- See Also:
QueryHelper.highestPrecedenceType2(org.hibernate.query.sqm.SqmExpressible<? extends X>, org.hibernate.query.sqm.SqmExpressible<? extends X>)
-
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.- See Also:
QueryHelper.highestPrecedenceType2(org.hibernate.query.sqm.SqmExpressible<? extends X>, org.hibernate.query.sqm.SqmExpressible<? extends X>)
-
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 TemporalType getSqlTemporalType(SqmExpressible<?> type)
-
getSqlTemporalType
public static TemporalType getSqlTemporalType(JdbcMapping jdbcMapping)
-
getSqlTemporalType
public static TemporalType getSqlTemporalType(JdbcMappingContainer jdbcMappings)
-
getSqlTemporalType
public static TemporalType getSqlTemporalType(MappingModelExpressible<?> type)
-
getSqlTemporalType
public static TemporalType getSqlTemporalType(JdbcType descriptor)
-
getSqlTemporalType
protected static 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)
-
-