Class ImmutableUserType<T>

java.lang.Object
ch.tocco.nice2.persist.core.api.hibernate.usertype.ImmutableUserType<T>
All Implemented Interfaces:
org.hibernate.usertype.UserType
Direct Known Subclasses:
BinaryUserType, CompressedTextUserType, EncodedPasswordUserType, HtmlUserType, LoginUserType, PhoneUserType, UuidToStringUserType

public abstract class ImmutableUserType<T> extends Object implements org.hibernate.usertype.UserType
Base class for immutable user types. Based on https://vladmihalcea.com/2016/09/22/how-to-implement-a-custom-basic-type-using-hibernate-usertype/
  • Constructor Details

    • ImmutableUserType

      protected ImmutableUserType(Class<T> clazz)
  • Method Details

    • nullSafeGet

      public Object nullSafeGet(ResultSet rs, String[] names, org.hibernate.engine.spi.SharedSessionContractImplementor session, Object owner) throws SQLException
      Specified by:
      nullSafeGet in interface org.hibernate.usertype.UserType
      Throws:
      SQLException
    • nullSafeSet

      public void nullSafeSet(PreparedStatement st, Object value, int index, org.hibernate.engine.spi.SharedSessionContractImplementor session) throws SQLException
      Specified by:
      nullSafeSet in interface org.hibernate.usertype.UserType
      Throws:
      SQLException
    • get

      protected abstract T get(ResultSet rs, String[] names, org.hibernate.engine.spi.SharedSessionContractImplementor session, Object owner) throws SQLException
      Throws:
      SQLException
    • set

      protected abstract void set(PreparedStatement st, T value, int index, org.hibernate.engine.spi.SharedSessionContractImplementor session) throws SQLException
      Throws:
      SQLException
    • returnedClass

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

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

      public int hashCode(Object x)
      Specified by:
      hashCode in interface org.hibernate.usertype.UserType
    • deepCopy

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

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

      public Serializable disassemble(Object o)
      Specified by:
      disassemble in interface org.hibernate.usertype.UserType
    • assemble

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

      public Object replace(Object o, Object target, Object owner)
      Specified by:
      replace in interface org.hibernate.usertype.UserType