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.metamodel.model.domain.DomainType<T>, 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.metamodel.model.domain.DomainType<T>, org.hibernate.metamodel.mapping.BasicValuedMapping
Very convenient base class for implementing immutable object types using Hibernate UserType.
Author:
Vlad Mihalcea
  • Nested Class Summary

    Nested classes/interfaces inherited from interface org.hibernate.metamodel.mapping.Bindable

    org.hibernate.metamodel.mapping.Bindable.JdbcValuesBiConsumer<X extends Object,Y extends Object>, org.hibernate.metamodel.mapping.Bindable.JdbcValuesConsumer
  • Constructor Summary

    Constructors
    Constructor
    Description
    MutableType(Class<T> clazz, JDBC jdbcTypeDescriptor, JAVA javaTypeDescriptor)
    Initialization constructor taking the Class and using the default Configuration object.
    MutableType(Class<T> clazz, JDBC jdbcTypeDescriptor, JAVA javaTypeDescriptor, Configuration configuration)
    Initialization constructor taking the Class and using the provided Configuration object.
  • Method Summary

    Modifier and Type
    Method
    Description
    assemble(Serializable cached, Object owner)
     
    deepCopy(T value)
     
    disassemble(Object value, org.hibernate.engine.spi.SharedSessionContractImplementor session)
     
    disassemble(T value)
     
    boolean
    equals(T x, T y)
     
    <X, Y> int
    forEachDisassembledJdbcValue(Object value, int offset, X x, Y y, org.hibernate.metamodel.mapping.Bindable.JdbcValuesBiConsumer<X,Y> valuesConsumer, org.hibernate.engine.spi.SharedSessionContractImplementor session)
     
    int
    forEachJdbcType(int offset, org.hibernate.internal.util.IndexedConsumer<org.hibernate.metamodel.mapping.JdbcMapping> action)
     
     
     
    org.hibernate.type.descriptor.java.JavaType<T>
     
     
    org.hibernate.metamodel.mapping.JdbcMapping
     
     
    org.hibernate.metamodel.mapping.MappingType
     
    int
     
    int
     
    boolean
     
    nullSafeGet(ResultSet rs, int position, org.hibernate.engine.spi.SharedSessionContractImplementor session, Object owner)
     
    void
    nullSafeSet(PreparedStatement st, Object value, int index, org.hibernate.engine.spi.SharedSessionContractImplementor session)
     
    replace(T detached, T managed, Object owner)
     
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.hibernate.metamodel.mapping.BasicValuedMapping

    addToCacheKey, getJdbcMapping, getJdbcTypeCount, getSingleJdbcMapping

    Methods inherited from interface org.hibernate.metamodel.mapping.Bindable

    forEachDisassembledJdbcValue, forEachDisassembledJdbcValue, forEachDisassembledJdbcValue, forEachJdbcType, forEachJdbcValue, forEachJdbcValue, forEachJdbcValue, forEachJdbcValue

    Methods inherited from interface org.hibernate.metamodel.model.domain.DomainType

    getSqmType, getTupleLength

    Methods inherited from interface org.hibernate.query.sqm.SqmExpressible

    getRelationalJavaType, getTypeName, isInstance, resolveExpressible

    Methods inherited from interface org.hibernate.usertype.UserType

    getDefaultSqlLength, getDefaultSqlPrecision, getDefaultSqlScale, getJdbcType, getValueConverter

    Methods inherited from interface org.hibernate.metamodel.mapping.ValueMapping

    treatAs
  • 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.BasicValuedMapping
      Specified by:
      disassemble in interface org.hibernate.metamodel.mapping.Bindable
    • forEachDisassembledJdbcValue

      public <X, Y> int forEachDisassembledJdbcValue(Object value, int offset, X x, Y y, org.hibernate.metamodel.mapping.Bindable.JdbcValuesBiConsumer<X,Y> 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.internal.util.IndexedConsumer<org.hibernate.metamodel.mapping.JdbcMapping> action)
      Specified by:
      forEachJdbcType in interface org.hibernate.metamodel.mapping.JdbcMappingContainer