Class UserComponentType<T>

All Implemented Interfaces:
Serializable, BindableType, OutputableType, CompositeType, ProcedureParameterExtractionAware, CompositeTypeImplementor, Type

public class UserComponentType<T> extends ComponentType
Since:
6.3
See Also:
  • Constructor Details

    • UserComponentType

      public UserComponentType(Component component, int[] originalPropertyOrder, CompositeUserType<T> compositeUserType)
  • Method Details

    • isEqual

      public boolean isEqual(Object x, Object y) throws HibernateException
      Description copied from interface: Type
      Compare two instances of the class mapped by this type for persistence "equality", that is, equality of persistent state. For most types this could simply delegate to equals().

      This should always equate to some form of comparison of the value's internal state. As an example, for Java's Date class, the comparison should be of its internal state, but based only on the specific part which is persistent (the timestamp, date, or time).

      Specified by:
      isEqual in interface Type
      Overrides:
      isEqual in class ComponentType
      Parameters:
      x - The first value
      y - The second value
      Returns:
      True if there are considered equal (see discussion above).
      Throws:
      HibernateException - A problem occurred performing the comparison
    • isEqual

      public boolean isEqual(Object x, Object y, SessionFactoryImplementor factory) throws HibernateException
      Description copied from interface: Type
      Compare two instances of the class mapped by this type for persistence "equality", that is, equality of persistent state. For most types this could simply delegate to Type.isEqual(Object, Object).

      This should always equate to some form of comparison of the value's internal state. As an example, for Java's Date class, the comparison should be of its internal state, but based only on the specific part which is persistent (the timestamp, date, or time).

      Specified by:
      isEqual in interface Type
      Overrides:
      isEqual in class ComponentType
      Parameters:
      x - The first value
      y - The second value
      factory - The session factory
      Returns:
      True if there are considered equal (see discussion above).
      Throws:
      HibernateException - A problem occurred performing the comparison
    • getHashCode

      public int getHashCode(Object x)
      Description copied from interface: Type
      Get a hash code, consistent with persistence "equality". For most types this could simply delegate to the given value's hashCode.
      Specified by:
      getHashCode in interface Type
      Overrides:
      getHashCode in class ComponentType
      Parameters:
      x - The value for which to retrieve a hash code
      Returns:
      The hash code
    • getHashCode

      public int getHashCode(Object x, SessionFactoryImplementor factory)
      Description copied from interface: Type
      Get a hash code, consistent with persistence "equality". For most types this could simply delegate to Type.getHashCode(Object).
      Specified by:
      getHashCode in interface Type
      Overrides:
      getHashCode in class ComponentType
      Parameters:
      x - The value for which to retrieve a hash code
      factory - The session factory
      Returns:
      The hash code
    • deepCopy

      public Object deepCopy(Object component, SessionFactoryImplementor factory)
      Description copied from interface: Type
      Return a deep copy of the persistent state, stopping at entities and at collections.
      Specified by:
      deepCopy in interface Type
      Overrides:
      deepCopy in class ComponentType
      Parameters:
      component - The value to be copied
      factory - The session factory
      Returns:
      The deep copy
    • replace

      public Object replace(Object original, Object target, SharedSessionContractImplementor session, Object owner, Map<Object,Object> copyCache)
      Description copied from interface: Type
      During merge, replace the existing (target) value in the entity we are merging to with a new (original) value from the detached entity we are merging. For immutable objects, or null values, it is safe to simply return the first parameter. For mutable objects, it is safe to return a copy of the first parameter. For objects with component values, it might make sense to recursively replace component values.
      Specified by:
      replace in interface Type
      Overrides:
      replace in class ComponentType
      Parameters:
      original - the value from the detached entity being merged
      target - the value in the managed entity
      session - The originating session
      owner - The owner of the value
      copyCache - The cache of already copied/replaced values
      Returns:
      the value to be merged
    • replace

      public Object replace(Object original, Object target, SharedSessionContractImplementor session, Object owner, Map<Object,Object> copyCache, ForeignKeyDirection foreignKeyDirection)
      Description copied from interface: Type
      During merge, replace the existing (target) value in the entity we are merging to with a new (original) value from the detached entity we are merging. For immutable objects, or null values, it is safe to simply return the first parameter. For mutable objects, it is safe to return a copy of the first parameter. For objects with component values, it might make sense to recursively replace component values.
      Specified by:
      replace in interface Type
      Overrides:
      replace in class ComponentType
      Parameters:
      original - the value from the detached entity being merged
      target - the value in the managed entity
      session - The originating session
      owner - The owner of the value
      copyCache - The cache of already copied/replaced values
      foreignKeyDirection - For associations, which direction does the foreign key point?
      Returns:
      the value to be merged
    • disassemble

      public Serializable disassemble(Object value, SessionFactoryImplementor sessionFactory) throws HibernateException
      Description copied from interface: Type
      Return a disassembled representation of the object. This is the representation that is stored in the second-level cache.

      A reference to an associated entity should be disassembled to its primary key value.

      A high-quality implementation of this method should ensure that:

       Objects.equals(disassemble(x,s), disassemble(y,s)) == isEqual(x,y,sf)
       

      and that:

       Objects.equals(x, assemble(disassemble(x,s),s,o))
       

      That is, the implementation must be consistent with Type.isEqual(Object, Object, SessionFactoryImplementor) and with Type.assemble(Serializable, SharedSessionContractImplementor, Object).

      Specified by:
      disassemble in interface Type
      Overrides:
      disassemble in class ComponentType
      Parameters:
      value - the value to cache
      sessionFactory - the session factory
      Returns:
      the disassembled, deep cloned state
      Throws:
      HibernateException - An error from Hibernate
    • disassemble

      public Serializable disassemble(Object value, SharedSessionContractImplementor session, Object owner) throws HibernateException
      Description copied from interface: Type
      Return a disassembled representation of the object. This is the representation that is stored in the second-level cache.

      A reference to an associated entity should be disassembled to its primary key value.

      Specified by:
      disassemble in interface Type
      Overrides:
      disassemble in class ComponentType
      Parameters:
      value - the value to cache
      session - the originating session
      owner - optional parent entity object (needed for collections)
      Returns:
      the disassembled, deep cloned state
      Throws:
      HibernateException - An error from Hibernate
    • assemble

      public Object assemble(Serializable object, SharedSessionContractImplementor session, Object owner) throws HibernateException
      Description copied from interface: Type
      Reconstruct the object from its disassembled state. This function is the inverse of Type.disassemble(Object, SharedSessionContractImplementor, Object).
      Specified by:
      assemble in interface Type
      Overrides:
      assemble in class ComponentType
      Parameters:
      object - the disassembled state from the cache
      session - the originating session
      owner - the parent entity object
      Returns:
      the (re)assembled object
      Throws:
      HibernateException - An error from Hibernate
    • replacePropertyValues

      public Object replacePropertyValues(Object component, Object[] values, SharedSessionContractImplementor session) throws HibernateException
      Description copied from interface: CompositeType
      Inject property values onto the given component instance, or return a new instance with the given property values.
      Specified by:
      replacePropertyValues in interface CompositeType
      Overrides:
      replacePropertyValues in class ComponentType
      Parameters:
      component - The component instance
      values - The values to inject
      Returns:
      A new instance as necessary
      Throws:
      HibernateException - Indicates an issue performing the injection