Package org.hibernate.type

Interface Type

    • Method Detail

      • isAssociationType

        boolean isAssociationType()
        Return true if the implementation is castable toAssociationType. This does not necessarily imply that the type actually represents an association. Shortcut fortype instanceof AssociationType.
        Returns:
        True if this type is also anAssociationType implementor; false otherwise.
      • isEntityType

        boolean isEntityType()
        Return true if the implementation is castable toEntityType. Shortcut fortype instanceof EntityType.

        AnEntityType is additionally anAssociationType; so if this method returns true,isAssociationType() should also return true.

        Returns:
        True if this type is also anEntityType implementor; false otherwise.
      • isAnyType

        boolean isAnyType()
        Return true if the implementation is castable toAnyType. Shortcut fortype instanceof AnyType.

        AnAnyType is additionally anAssociationType; so if this method returns true, thenisAssociationType() should also return true.

        Returns:
        True if this type is also anAnyType implementor; false otherwise.
      • isComponentType

        boolean isComponentType()
        Return true if the implementation is castable toCompositeType. Shortcut fortype instanceof CompositeType.

        A component type may own collections or associations and hence must provide certain extra functionality.

        Returns:
        True if this type is also aCompositeType implementor; false otherwise.
      • getReturnedClass

        Class<?> getReturnedClass()
        The class handled by this type.
        Returns:
        The Java class handled by this type.
      • getReturnedClassName

        default String getReturnedClassName()
        The qualified name of the class handled by this type.
        Returns:
        The qualified Java class name.
        Since:
        6.5
      • isSame

        boolean isSame​(@NullableObject x,               @NullableObject y)        throwsHibernateException
        Compare two instances of the class mapped by this type for persistence "equality", that is, equality of persistent state, taking a shortcut for entity references.

        For most types this should boil down to anequality comparison of the given values, and it's reasonable to simply delegate toisEqual(Object, Object). But for associations the semantics are a bit different.

        Parameters:
        x - The first value
        y - The second value
        Returns:
        True if there are considered the same (see discussion above).
        Throws:
        HibernateException - A problem occurred performing the comparison
      • isEqual

        boolean isEqual​(@NullableObject x,                @NullableObject y)         throwsHibernateException
        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 toequals().

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

        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

        boolean isEqual​(@NullableObject x,                @NullableObject y,SessionFactoryImplementor factory)         throwsHibernateException
        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 toisEqual(Object, Object).

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

        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

        int getHashCode​(Object x)         throwsHibernateException
        Get a hash code, consistent with persistence "equality". For most types this could simply delegate to the given value'shashCode.
        Parameters:
        x - The value for which to retrieve a hash code
        Returns:
        The hash code
        Throws:
        HibernateException - A problem occurred calculating the hash code
      • getTypeForEqualsHashCode

        default @NullableType getTypeForEqualsHashCode()
        The type to use forequals() andhashCode() computation. Whennull, useObject.equals(Object) andObject.hashCode(). This is useful to avoid mega-morphic callsites.
      • isDirty

        boolean isDirty​(@NullableObject old,                @NullableObject current,SharedSessionContractImplementor session)         throwsHibernateException
        Should the parent be considered dirty, given both the old and current value?
        Parameters:
        old - the old value
        current - the current value
        session - The session from which the request originated.
        Returns:
        true if the field is dirty
        Throws:
        HibernateException - A problem occurred performing the checking
      • isDirty

        boolean isDirty​(@NullableObject oldState,                @NullableObject currentState,                boolean[] checkable,SharedSessionContractImplementor session)         throwsHibernateException
        Should the parent be considered dirty, given both the old and current value?
        Parameters:
        oldState - the old value
        currentState - the current value
        checkable - An array of booleans indicating which columns making up the value are actually checkable
        session - The session from which the request originated.
        Returns:
        true if the field is dirty
        Throws:
        HibernateException - A problem occurred performing the checking
      • nullSafeSet

        void nullSafeSet​(PreparedStatement st,                 @NullableObject value,                 int index,                 boolean[] settable,SharedSessionContractImplementor session)          throwsHibernateException,SQLException
        Bind a value represented by an instance of themapped class to the given JDBCPreparedStatement, ignoring some columns as dictated by thesettable parameter. Implementors should handle the possibility of null values. A multi-column type should bind parameters starting fromindex.
        Parameters:
        st - The JDBC prepared statement to which to bind
        value - the object to write
        index - starting parameter bind index
        settable - an array indicating which columns to bind/ignore
        session - The originating session
        Throws:
        HibernateException - An error from Hibernate
        SQLException - An error from the JDBC driver
      • getName

        String getName()
        Returns the abbreviated name of the type.
        Returns:
        the Hibernate type name
      • isMutable

        boolean isMutable()
        Are objects of this type mutable with respect to the referencing object? Entities and collections are considered immutable because they manage their own internal state.
        Returns:
        boolean
      • disassemble

        @NullableSerializable disassemble​(@NullableObject value,                                   @NullableSharedSessionContractImplementor session,                                   @NullableObject owner)                            throwsHibernateException
        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.

        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
      • beforeAssemble

        @Deprecated(forRemoval=true,since="6.6")void beforeAssemble​(Serializable cached,SharedSessionContractImplementor session)
        Deprecated, for removal: This API element is subject to removal in a future version.
        Is not called anymore
        Called before assembling a query result set from the query cache, to allow batch fetching of entities missing from the second-level cache.
        Parameters:
        cached - The key
        session - The originating session
      • replace

        @NullableObject replace​(@NullableObject original,                         @NullableObject target,SharedSessionContractImplementor session,Object owner,Map<Object,​Object> copyCache)                  throwsHibernateException
        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.
        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
        Throws:
        HibernateException - An error from Hibernate
      • replace

        @NullableObject replace​(@NullableObject original,                         @NullableObject target,SharedSessionContractImplementor session,Object owner,Map<Object,​Object> copyCache,ForeignKeyDirection foreignKeyDirection)                  throwsHibernateException
        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.
        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
        Throws:
        HibernateException - An error from Hibernate
      • toColumnNullness

        boolean[] toColumnNullness​(@NullableObject value,Mapping mapping)
        Given an instance of the type, return an array ofboolean values indicating which mapped columns would be null.
        Parameters:
        value - an instance of the type
        mapping - The mapping abstraction
        Returns:
        array indicating column nullness for a value instance