Interface Type

    • Method Detail

      • isAssociationType

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

        boolean isEntityType()
        Return true if the implementation is castable to EntityType. Shortcut for type instanceof EntityType.

        An EntityType is additionally an AssociationType; so if this method returns true, isAssociationType() should also return true.

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

        boolean isAnyType()
        Return true if the implementation is castable to AnyType. Shortcut for type instanceof AnyType.

        An AnyType is additionally an AssociationType; so if this method returns true, then isAssociationType() should also return true.

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

        boolean isComponentType()
        Return true if the implementation is castable to CompositeType. Shortcut for type instanceof CompositeType.

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

        Returns:
        True if this type is also a CompositeType implementor; false otherwise.
      • getColumnSpan

        int getColumnSpan​(Mapping mapping)
                   throws MappingException
        How many columns are used to persist this type?

        Always the same as getSqlTypCodes(mapping).length.

        Parameters:
        mapping - The mapping object :/
        Returns:
        The number of columns
        Throws:
        MappingException - Generally indicates an issue accessing the passed mapping object.
      • getReturnedClass

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

        boolean isSame​(Object x,
                       Object y)
                throws HibernateException
        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 an equality comparison of the given values, and it's reasonable to simply delegate to isEqual(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​(Object x,
                        Object y)
                 throws HibernateException
        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).

        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​(Object x,
                        Object y,
                        SessionFactoryImplementor factory)
                 throws HibernateException
        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 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).

        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)
                 throws HibernateException
        Get a hash code, consistent with persistence "equality". For most types this could simply delegate to the given value's hashCode.
        Parameters:
        x - The value for which to retrieve a hash code
        Returns:
        The hash code
        Throws:
        HibernateException - A problem occurred calculating the hash code
      • isDirty

        boolean isDirty​(Object old,
                        Object current,
                        SharedSessionContractImplementor session)
                 throws HibernateException
        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​(Object oldState,
                        Object currentState,
                        boolean[] checkable,
                        SharedSessionContractImplementor session)
                 throws HibernateException
        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,
                         Object value,
                         int index,
                         boolean[] settable,
                         SharedSessionContractImplementor session)
                  throws HibernateException,
                         SQLException
        Bind a value represented by an instance of the mapped class to the given JDBC PreparedStatement, ignoring some columns as dictated by the settable parameter. Implementors should handle the possibility of null values. A multi-column type should bind parameters starting from index.
        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

        Serializable disassemble​(Object value,
                                 SharedSessionContractImplementor session,
                                 Object owner)
                          throws HibernateException
        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

        void beforeAssemble​(Serializable cached,
                            SharedSessionContractImplementor session)
        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

        Object replace​(Object original,
                       Object target,
                       SharedSessionContractImplementor session,
                       Object owner,
                       Map<Object,​Object> copyCache)
                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.
        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

        Object replace​(Object original,
                       Object target,
                       SharedSessionContractImplementor session,
                       Object owner,
                       Map<Object,​Object> copyCache,
                       ForeignKeyDirection foreignKeyDirection)
                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.
        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​(Object value,
                                   Mapping mapping)
        Given an instance of the type, return an array of boolean 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