Class DescriptorImmutableType<T,JDBC extends org.hibernate.type.descriptor.jdbc.JdbcType,JAVA extends org.hibernate.type.descriptor.java.JavaType<T>>

java.lang.Object
io.hypersistence.utils.hibernate.type.ImmutableType<T>
io.hypersistence.utils.hibernate.type.DescriptorImmutableType<T,JDBC,JAVA>
All Implemented Interfaces:
Serializable, org.hibernate.metamodel.model.domain.DomainType<T>, org.hibernate.query.BindableType<T>, org.hibernate.query.sqm.SqmExpressible<T>, org.hibernate.type.Type, org.hibernate.usertype.DynamicParameterizedType, org.hibernate.usertype.EnhancedUserType<T>, org.hibernate.usertype.ParameterizedType, org.hibernate.usertype.UserType<T>
Direct Known Subclasses:
CurrencyUnitType, Iso8601MonthType, MonthDayDateType, MonthDayIntegerType, YearMonthDateType, YearMonthEpochType, YearMonthIntegerType, YearMonthTimestampType, YearType, ZoneIdType

public abstract class DescriptorImmutableType<T,JDBC extends org.hibernate.type.descriptor.jdbc.JdbcType,JAVA extends org.hibernate.type.descriptor.java.JavaType<T>> extends ImmutableType<T> implements org.hibernate.query.BindableType<T>, org.hibernate.metamodel.model.domain.DomainType<T>, org.hibernate.usertype.DynamicParameterizedType
Very convenient base class for implementing immutable object types using Hibernate UserType using the JdbcType and JavaType descriptors.
Author:
Vlad Mihalcea
See Also:
  • Constructor Details

    • DescriptorImmutableType

      public DescriptorImmutableType(Class<T> clazz, JDBC jdbcTypeDescriptor, JAVA javaTypeDescriptor)
    • DescriptorImmutableType

      public DescriptorImmutableType(Class<T> clazz, JDBC jdbcTypeDescriptor, JAVA javaTypeDescriptor, Configuration configuration)
  • Method Details

    • nullSafeGet

      public T nullSafeGet(ResultSet rs, int position, org.hibernate.engine.spi.SharedSessionContractImplementor session, Object owner) throws SQLException
      Specified by:
      nullSafeGet in interface org.hibernate.usertype.UserType<T>
      Overrides:
      nullSafeGet in class ImmutableType<T>
      Throws:
      SQLException
    • nullSafeSet

      public void nullSafeSet(PreparedStatement st, Object value, int index, org.hibernate.engine.spi.SharedSessionContractImplementor session) throws org.hibernate.HibernateException, SQLException
      Specified by:
      nullSafeSet in interface org.hibernate.type.Type
      Specified by:
      nullSafeSet in interface org.hibernate.usertype.UserType<T>
      Overrides:
      nullSafeSet in class ImmutableType<T>
      Throws:
      org.hibernate.HibernateException
      SQLException
    • get

      protected T get(ResultSet rs, int position, org.hibernate.engine.spi.SharedSessionContractImplementor session, Object owner) throws SQLException
      Description copied from class: ImmutableType
      Get the column value from the JDBC ResultSet.
      Specified by:
      get in class ImmutableType<T>
      Parameters:
      rs - JDBC ResultSet
      position - database column position
      session - current Hibernate Session
      owner - current Hibernate SessionFactoryImplementor
      Returns:
      column value
      Throws:
      SQLException - in case of failure
    • set

      protected void set(PreparedStatement st, T value, int index, org.hibernate.engine.spi.SharedSessionContractImplementor session) throws SQLException
      Description copied from class: ImmutableType
      Set the column value on the provided JDBC PreparedStatement.
      Specified by:
      set in class ImmutableType<T>
      Parameters:
      st - JDBC PreparedStatement
      value - database column value
      index - database column index
      session - current Hibernate Session
      Throws:
      SQLException - in case of failure
    • getSqlType

      public int getSqlType()
      Specified by:
      getSqlType in interface org.hibernate.usertype.UserType<T>
    • getBindableJavaType

      public Class<T> getBindableJavaType()
      Specified by:
      getBindableJavaType in interface org.hibernate.query.BindableType<T>
    • getExpressibleJavaType

      public org.hibernate.type.descriptor.java.JavaType<T> getExpressibleJavaType()
      Specified by:
      getExpressibleJavaType in interface org.hibernate.query.sqm.SqmExpressible<T>
    • setParameterValues

      public void setParameterValues(Properties parameters)
      Specified by:
      setParameterValues in interface org.hibernate.usertype.ParameterizedType