接口 UserType

  • 所有已知子接口:
    EnhancedUserType, UserVersionType
    所有已知实现类:
    EnumType

    public interface UserType
    This interface should be implemented by user-defined "types". A "type" class is not the actual property type - it is a class that knows how to serialize instances of another class to and from JDBC.

    This interface
    • abstracts user code from future changes to the Type interface,
    • simplifies the implementation of custom types and
    • hides certain "internal" interfaces from user code.

    Implementors must be immutable and must declare a public default constructor.

    The actual class mapped by a UserType may be just about anything.

    CompositeUserType provides an extended version of this interface that is useful for more complex cases.

    Alternatively, custom types could implement Type directly or extend one of the abstract classes in org.hibernate.type. This approach risks future incompatible changes to classes or interfaces in that package.
    作者:
    Gavin King
    另请参阅:
    for more complex cases, Type
    • 方法详细资料

      • sqlTypes

        int[] sqlTypes()
        Return the SQL type codes for the columns mapped by this type. The codes are defined on java.sql.Types.
        返回:
        int[] the typecodes
        另请参阅:
        Types
      • returnedClass

        Class returnedClass()
        The class returned by nullSafeGet().
        返回:
        Class
      • equals

        boolean equals​(Object x,
                       Object y)
                throws HibernateException
        Compare two instances of the class mapped by this type for persistence "equality". Equality of the persistent state.
        参数:
        x -
        y -
        返回:
        boolean
        抛出:
        HibernateException
      • deepCopy

        Object deepCopy​(Object value)
                 throws HibernateException
        Return a deep copy of the persistent state, stopping at entities and at collections. It is not necessary to copy immutable objects, or null values, in which case it is safe to simply return the argument.
        参数:
        value - the object to be cloned, which may be null
        返回:
        Object a copy
        抛出:
        HibernateException
      • isMutable

        boolean isMutable()
        Are objects of this type mutable?
        返回:
        boolean
      • disassemble

        Serializable disassemble​(Object value)
                          throws HibernateException
        Transform the object into its cacheable representation. At the very least this method should perform a deep copy if the type is mutable. That may not be enough for some implementations, however; for example, associations must be cached as identifier values. (optional operation)
        参数:
        value - the object to be cached
        返回:
        a cacheable representation of the object
        抛出:
        HibernateException
      • assemble

        Object assemble​(Serializable cached,
                        Object owner)
                 throws HibernateException
        Reconstruct an object from the cacheable representation. At the very least this method should perform a deep copy if the type is mutable. (optional operation)
        参数:
        cached - the object to be cached
        owner - the owner of the cached object
        返回:
        a reconstructed object from the cacheable representation
        抛出:
        HibernateException
      • replace

        Object replace​(Object original,
                       Object target,
                       Object owner)
                throws HibernateException
        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.
        参数:
        original - the value from the detached entity being merged
        target - the value in the managed entity
        返回:
        the value to be merged
        抛出:
        HibernateException