Class MutableType<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.MutableType<T,JDBC,JAVA>
All Implemented Interfaces:
org.hibernate.metamodel.mapping.BasicValuedMapping, org.hibernate.metamodel.mapping.Bindable, org.hibernate.metamodel.mapping.JdbcMappingContainer, org.hibernate.metamodel.mapping.MappingModelExpressible, org.hibernate.metamodel.mapping.SqlExpressible, org.hibernate.metamodel.mapping.ValueMapping, org.hibernate.query.BindableType<T>, org.hibernate.query.sqm.SqmExpressible<T>, org.hibernate.type.descriptor.java.JavaTypedExpressible, org.hibernate.usertype.UserType<T>
Direct Known Subclasses:
MutableDynamicParameterizedType

public abstract class MutableType<T,JDBC extends org.hibernate.type.descriptor.jdbc.JdbcType,JAVA extends org.hibernate.type.descriptor.java.JavaType<T>> extends Object implements org.hibernate.usertype.UserType<T>, org.hibernate.query.BindableType<T>, org.hibernate.query.sqm.SqmExpressible<T>, org.hibernate.metamodel.mapping.BasicValuedMapping
Very convenient base class for implementing immutable object types using Hibernate UserType.
Author:
Vlad Mihalcea
  • Constructor Details

    • MutableType

      public MutableType(Class<T> clazz, JDBC jdbcTypeDescriptor, JAVA javaTypeDescriptor)
      Initialization constructor taking the Class and using the default Configuration object.
      Parameters:
      clazz - The class returned by UserType.nullSafeGet(ResultSet, int, SharedSessionContractImplementor, Object).
      jdbcTypeDescriptor - the JDBC type descriptor
      javaTypeDescriptor - the Java type descriptor
    • MutableType

      public MutableType(Class<T> clazz, JDBC jdbcTypeDescriptor, JAVA javaTypeDescriptor, Configuration configuration)
      Initialization constructor taking the Class and using the provided Configuration object.
      Parameters:
      clazz - The class returned by UserType.nullSafeGet(ResultSet, int, SharedSessionContractImplementor, Object).
      jdbcTypeDescriptor - the JDBC type descriptor
      javaTypeDescriptor - the Java type descriptor
      configuration - the configuration
  • Method Details

    • getJdbcTypeDescriptor

      public JDBC getJdbcTypeDescriptor()
    • getJavaTypeDescriptor

      public JAVA getJavaTypeDescriptor()
    • getConfiguration

      public Configuration getConfiguration()
    • equals

      public boolean equals(T x, T y)
      Specified by:
      equals in interface org.hibernate.usertype.UserType<T>
    • hashCode

      public int hashCode(T x)
      Specified by:
      hashCode in interface org.hibernate.usertype.UserType<T>
    • 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>
      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.usertype.UserType<T>
      Throws:
      org.hibernate.HibernateException
      SQLException
    • deepCopy

      public T deepCopy(T value)
      Specified by:
      deepCopy in interface org.hibernate.usertype.UserType<T>
    • isMutable

      public boolean isMutable()
      Specified by:
      isMutable in interface org.hibernate.usertype.UserType<T>
    • disassemble

      public Serializable disassemble(T value)
      Specified by:
      disassemble in interface org.hibernate.usertype.UserType<T>
    • assemble

      public T assemble(Serializable cached, Object owner)
      Specified by:
      assemble in interface org.hibernate.usertype.UserType<T>
    • replace

      public T replace(T detached, T managed, Object owner)
      Specified by:
      replace in interface org.hibernate.usertype.UserType<T>
    • getSqlType

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

      public Class<T> returnedClass()
      Specified by:
      returnedClass 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.type.descriptor.java.JavaTypedExpressible<T>
      Specified by:
      getExpressibleJavaType in interface org.hibernate.query.sqm.SqmExpressible<T>
      Specified by:
      getExpressibleJavaType in interface org.hibernate.metamodel.mapping.ValueMapping
    • getJdbcMapping

      public org.hibernate.metamodel.mapping.JdbcMapping getJdbcMapping()
      Specified by:
      getJdbcMapping in interface org.hibernate.metamodel.mapping.BasicValuedMapping
      Specified by:
      getJdbcMapping in interface org.hibernate.metamodel.mapping.SqlExpressible
    • getMappedType

      public org.hibernate.metamodel.mapping.MappingType getMappedType()
      Specified by:
      getMappedType in interface org.hibernate.metamodel.mapping.ValueMapping
    • disassemble

      public Object disassemble(Object value, org.hibernate.engine.spi.SharedSessionContractImplementor session)
      Specified by:
      disassemble in interface org.hibernate.metamodel.mapping.Bindable
    • forEachDisassembledJdbcValue

      public int forEachDisassembledJdbcValue(Object value, org.hibernate.sql.ast.Clause clause, int offset, org.hibernate.metamodel.mapping.Bindable.JdbcValuesConsumer valuesConsumer, org.hibernate.engine.spi.SharedSessionContractImplementor session)
      Specified by:
      forEachDisassembledJdbcValue in interface org.hibernate.metamodel.mapping.Bindable
    • forEachJdbcType

      public int forEachJdbcType(int offset, org.hibernate.mapping.IndexedConsumer<org.hibernate.metamodel.mapping.JdbcMapping> action)
      Specified by:
      forEachJdbcType in interface org.hibernate.metamodel.mapping.JdbcMappingContainer