Class TypeConfiguration

java.lang.Object
org.hibernate.type.spi.TypeConfiguration
All Implemented Interfaces:
Serializable, SessionFactoryObserver

@Incubating 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 a TypeConfiguration. We always obtain a reference to a Type via the TypeConfiguration associated with the current persistence unit.

On the other hand, a Type does not inherently have access to its parent TypeConfiguration since extensions may contribute instances of Type, via TypeContributions, for example, and the instantiation of such instances occurs outside the control of Hibernate.

In particular, a custom TypeContributor may contribute types to a TypeConfiguration.

If a Type requires access to the parent TypeConfiguration, it should implement TypeConfigurationAware.

Since:
5.3
See Also:
  • Constructor Details

    • TypeConfiguration

      public TypeConfiguration()
  • Method Details

    • 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 use
      Obtain the MetadataBuildingContext currently scoping this TypeConfiguration.
      Returns:
      The MetadataBuildingContext
      API Note:
      Throws an exception if the TypeConfiguration is no longer scoped to the MetadataBuildingContext. See TypeConfiguration.Scope for more details regarding the stages a TypeConfiguration passes through.
    • scope

      public void scope(MetadataBuildingContext metadataBuildingContext)
      Scope this TypeConfiguration to the given MetadataBuildingContext.
      Parameters:
      metadataBuildingContext - a MetadataBuildingContext
      Implementation Note:
      The given factory is not yet fully-initialized!
    • scope

      public void scope(SessionFactoryImplementor sessionFactory)
      Scope this TypeConfiguration to the given SessionFactory.
      Parameters:
      sessionFactory - a SessionFactory that is in a very fragile state
      Implementation Note:
      The given factory is not yet fully-initialized!
    • getSessionFactory

      @Deprecated(since="6.2") public SessionFactoryImplementor getSessionFactory()
      Deprecated.
      This operation is not very typesafe, and we're migrating away from its use
      Obtain the SessionFactory currently scoping this TypeConfiguration.
      Returns:
      The SessionFactory to which this TypeConfiguration is scoped
      Throws:
      HibernateException - if the TypeConfiguration is not currently scoped to a SessionFactory (in a "runtime stage").
      API Note:
      Throws an exception if the TypeConfiguration is not yet scoped to a factory. See TypeConfiguration.Scope for more details regarding the stages a TypeConfiguration passes through (this is a "runtime stage").
    • getServiceRegistry

      @Deprecated(since="6.2") public ServiceRegistry getServiceRegistry()
      Deprecated.
      This simply isn't a very sensible place to hang the ServiceRegistry
      Obtain the ServiceRegistry scoped to this TypeConfiguration.
      Returns:
      The ServiceRegistry for the current scope
      API Note:
      The current TypeConfiguration.Scope will determine from where the ServiceRegistry is obtained.
    • getJpaCompliance

      @Deprecated(since="7.0", forRemoval=true) public JpaCompliance getJpaCompliance()
      Deprecated, for removal: This API element is subject to removal in a future version.
      No longer used
      Obtain the JpaCompliance setting.
    • entityClassForEntityName

      @Internal public Class<?> entityClassForEntityName(String entityName)
      Workaround for an issue faced in EntityType.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 interface SessionFactoryObserver
      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 interface SessionFactoryObserver
      Parameters:
      factory - The factory closed.
    • addBasicTypeRegistrationContributions

      public void addBasicTypeRegistrationContributions(List<BasicTypeRegistration> contributions)
    • resolveCastTargetType

      public BasicType<?> resolveCastTargetType(String name)
      Understands the following target type names for the cast() 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 via CharBooleanConverter)

      The type names are not case-sensitive.

    • resolveTupleType

      public SqmBindableType<?> resolveTupleType(List<? extends SqmTypedNode<?>> typedNodes)
    • resolveArithmeticType

      public @Nullable SqmBindableType<?> resolveArithmeticType(@Nullable SqmBindableType<?> firstType, @Nullable SqmBindableType<?> secondType, BinaryArithmeticOperator operator)
      See Also:
      • QueryHelper.highestPrecedenceType2(SqmBindableType, SqmBindableType)
    • resolveArithmeticType

      public @Nullable SqmBindableType<?> resolveArithmeticType(@Nullable SqmBindableType<?> firstType, @Nullable SqmBindableType<?> secondType)
      Determine the result type of an arithmetic operation as defined by the rules in section 6.5.8.1, taking converters into account.
      See Also:
      • QueryHelper.highestPrecedenceType2(SqmBindableType, SqmBindableType)
    • resolveArithmeticType

      public @Nullable SqmBindableType<?> resolveArithmeticType(SqmBindableType<?> expressible)
      Determine the result type of a unary arithmetic operation, taking converters into account.
    • getBasicTypeForGenericJavaType

      @Deprecated(since="7.2", forRemoval=true) public <J> @Nullable BasicType<J> getBasicTypeForGenericJavaType(Class<? super J> javaType, Type... typeArguments)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • getBasicTypeForJavaType

      public <J> @Nullable BasicType<J> getBasicTypeForJavaType(Class<J> javaClass)
    • getBasicTypeForJavaType

      public @Nullable BasicType<?> getBasicTypeForJavaType(Type javaType)
    • standardBasicTypeForJavaType

      public <J> BasicType<J> standardBasicTypeForJavaType(Class<J> javaClass)
    • standardBasicTypeForJavaType

      public BasicType<?> standardBasicTypeForJavaType(Type javaType)
    • standardBasicTypeForJavaType

      @Deprecated(since="7.2", forRemoval=true) public <J> BasicType<J> standardBasicTypeForJavaType(Class<J> javaClass, Function<JavaType<J>, BasicType<J>> creator)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • standardBasicTypeForJavaType

      @Deprecated(since="7.2", forRemoval=true) public <J> BasicType<?> standardBasicTypeForJavaType(Type javaType, Function<JavaType<J>, BasicType<J>> creator)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • getSqlTemporalType

      public @Nullable TemporalType getSqlTemporalType(@Nullable SqmExpressible<?> type)
    • getSqlTemporalType

      public static @Nullable TemporalType getSqlTemporalType(JdbcMapping jdbcMapping)
    • getSqlTemporalType

      public static @Nullable TemporalType getSqlTemporalType(JdbcMappingContainer jdbcMappings)
    • getSqlTemporalType

      public static @Nullable TemporalType getSqlTemporalType(MappingModelExpressible<?> type)
    • getSqlTemporalType

      public static @Nullable TemporalType getSqlTemporalType(JdbcType descriptor)
    • getSqlTemporalType

      protected static @Nullable TemporalType getSqlTemporalType(int jdbcTypeCode)
    • getSqlIntervalType

      public static @Nullable IntervalType getSqlIntervalType(JdbcMappingContainer jdbcMappings)
    • getSqlIntervalType

      public static @Nullable IntervalType getSqlIntervalType(JdbcType descriptor)
    • getSqlIntervalType

      protected static @Nullable IntervalType getSqlIntervalType(int jdbcTypeCode)
    • isJdbcTemporalType

      public static boolean isJdbcTemporalType(@Nullable SqmExpressible<?> type)
    • isDuration

      public static boolean isDuration(@Nullable SqmExpressible<?> type)
    • createMutabilityPlan

      @Internal public <J> MutabilityPlan<J> createMutabilityPlan(Class<? extends MutabilityPlan<?>> planClass)
    • getJsonFormatMapper

      @Internal @Incubating public final FormatMapper getJsonFormatMapper()
    • getXmlFormatMapper

      @Internal @Incubating public final FormatMapper getXmlFormatMapper()