Class BaseUserTypeSupport<T>

java.lang.Object
org.hibernate.usertype.BaseUserTypeSupport<T>
All Implemented Interfaces:
UserType<T>
Direct Known Subclasses:
UserTypeLegacyBridge, UserTypeSupport

public abstract class BaseUserTypeSupport<T> extends Object implements UserType<T>
  • Constructor Details

    • BaseUserTypeSupport

      public BaseUserTypeSupport()
  • Method Details

    • resolve

      protected abstract void resolve(BiConsumer<BasicJavaType<T>,JdbcType> resolutionConsumer)
    • jdbcType

      protected JdbcType jdbcType()
    • javaType

      protected BasicJavaType<T> javaType()
    • getSqlType

      public int getSqlType()
      Description copied from interface: UserType
      The JDBC/SQL type code for the database column mapped by this custom type.

      The type code is usually one of the standard type codes declared by SqlTypes, but it could be a database-specific code.

      Specified by:
      getSqlType in interface UserType<T>
      See Also:
    • returnedClass

      public Class<T> returnedClass()
      Description copied from interface: UserType
      The class returned by nullSafeGet().
      Specified by:
      returnedClass in interface UserType<T>
      Returns:
      Class
    • equals

      public boolean equals(T x, T y) throws HibernateException
      Description copied from interface: UserType
      Compare two instances of the Java class mapped by this custom type for persistence "equality", that is, equality of their persistent state.
      Specified by:
      equals in interface UserType<T>
      Throws:
      HibernateException
    • hashCode

      public int hashCode(T x) throws HibernateException
      Description copied from interface: UserType
      Get a hash code for the given instance of the Java class mapped by this custom type, consistent with the definition of persistence "equality" for this custom type.
      Specified by:
      hashCode in interface UserType<T>
      Throws:
      HibernateException
    • nullSafeGet

      public T nullSafeGet(ResultSet rs, int position, WrapperOptions options) throws SQLException
      Description copied from interface: UserType
      Read an instance of the Java class mapped by this custom type from the given JDBC ResultSet. Implementors must handle null column values.
      Specified by:
      nullSafeGet in interface UserType<T>
      Throws:
      SQLException
    • nullSafeSet

      public void nullSafeSet(PreparedStatement st, T value, int index, WrapperOptions options) throws SQLException
      Description copied from interface: UserType
      Write an instance of the Java class mapped by this custom type to the given JDBC PreparedStatement. Implementors must handle null values of the Java class. A multi-column type should be written to parameters starting from index.
      Specified by:
      nullSafeSet in interface UserType<T>
      Throws:
      SQLException
    • deepCopy

      public T deepCopy(T value) throws HibernateException
      Description copied from interface: UserType
      Return a clone of the given instance of the Java class mapped by this custom type.
      • It's not necessary to clone immutable objects. If the Java class mapped by this custom type is an immutable class, this method may safely just return its argument.
      • For mutable objects, it's necessary to deep copy persistent state, stopping at associations to other entities, and at persistent collections.
      • If the argument is a reference to an entity, just return the argument.
      • Finally, if the argument is null, just return null.
      Specified by:
      deepCopy in interface UserType<T>
      Parameters:
      value - the object to be cloned, which may be null
      Returns:
      a clone if the argument is mutable, or the argument if it's an immutable object
      Throws:
      HibernateException
    • isMutable

      public boolean isMutable()
      Description copied from interface: UserType
      Are instances of the Java class mapped by this custom type mutable or immutable?
      Specified by:
      isMutable in interface UserType<T>
      Returns:
      true if instances are mutable
    • disassemble

      public Serializable disassemble(T value) throws HibernateException
      Description copied from interface: UserType
      Transform the given value into a destructured representation, suitable for storage in the second-level cache. This method is called only during the process of writing the properties of an entity to the second-level cache.

      If the value is mutable then, at the very least, this method should perform a deep copy. That may not be enough for some types, however. For example, associations must be cached as identifier values.

      This is an optional operation, but, if left unimplemented, this type will not be cacheable in the second-level cache.

      Specified by:
      disassemble in interface UserType<T>
      Parameters:
      value - the object to be cached
      Returns:
      a cacheable representation of the object
      Throws:
      HibernateException
      See Also:
    • assemble

      public T assemble(Serializable cached, Object owner) throws HibernateException
      Description copied from interface: UserType
      Reconstruct a value from its destructured representation, during the process of reading the properties of an entity from the second-level cache.

      If the value is mutable then, at the very least, this method should perform a deep copy. That may not be enough for some types, however. For example, associations must be cached as identifier values.

      This is an optional operation, but, if left unimplemented, this type will not be cacheable in the second-level cache.

      Specified by:
      assemble in interface UserType<T>
      Parameters:
      cached - the object to be cached
      owner - the owner of the cached object
      Returns:
      a reconstructed object from the cacheable representation
      Throws:
      HibernateException
      See Also: