Interface EntityPersister

    • Method Detail

      • getEntityEntryFactory

        EntityEntryFactory getEntityEntryFactory()
        Get the EntityEntryFactory indicated for the entity mapped by this persister.
        Returns:
        The proper EntityEntryFactory.
      • getRootEntityName

        String getRootEntityName()
        Returns an object that identifies the space in which identifiers of this entity hierarchy are unique. Might be a table name, a JNDI URL, etc.
        Returns:
        The root entity name.
      • getEntityName

        String getEntityName()
        The entity name which this persister maps.
        Specified by:
        getEntityName in interface EntityMappingType
        Returns:
        The name of the entity which this persister maps.
      • getEntityMetamodel

        EntityMetamodel getEntityMetamodel()
        Retrieve the underlying entity metamodel instance.
        Returns:
        The metamodel
      • isSubclassEntityName

        boolean isSubclassEntityName​(String entityName)
        Determine whether the given name represents a subclass entity (or this entity itself) of the entity mapped by this persister.
        Parameters:
        entityName - The entity name to be checked.
        Returns:
        True if the given entity name represents either the entity mapped by this persister or one of its subclass entities; false otherwise.
      • getPropertySpaces

        String[] getPropertySpaces()
        Returns an array of objects that identify spaces in which properties of this entity are persisted, for instances of this class only.

        For most implementations, this returns the complete set of table names to which instances of the mapped entity are persisted (not accounting for superclass entity mappings).

        Returns:
        The property spaces.
      • getQuerySpaces

        Serializable[] getQuerySpaces()
        Returns an array of objects that identify spaces in which properties of this entity are persisted, for instances of this class and its subclasses.

        Much like getPropertySpaces(), except that here we include subclass entity spaces.

        Returns:
        The query spaces.
      • getSynchronizationSpaces

        default String[] getSynchronizationSpaces()
        The table names this entity needs to be synchronized against.

        Much like getPropertySpaces(), except that here we include subclass entity spaces.

        Returns:
        The synchronization spaces.
      • getSynchronizedQuerySpaces

        default String[] getSynchronizedQuerySpaces()
        Returns an array of objects that identify spaces in which properties of this entity are persisted, for instances of this class and its subclasses.

        Much like getPropertySpaces(), except that here we include subclass entity spaces.

        Returns:
        The query spaces.
      • hasProxy

        boolean hasProxy()
        Determine whether this entity supports dynamic proxies.
        Returns:
        True if the entity has dynamic proxy support; false otherwise.
      • hasCollections

        boolean hasCollections()
        Determine whether this entity contains references to persistent collections.
        Returns:
        True if the entity does contain persistent collections; false otherwise.
      • hasMutableProperties

        boolean hasMutableProperties()
        Determine whether any properties of this entity are considered mutable.
        Returns:
        True if any properties of the entity are mutable; false otherwise (meaning none are).
      • hasSubselectLoadableCollections

        boolean hasSubselectLoadableCollections()
        Determine whether this entity contains references to persistent collections which are fetchable by subselect?
        Returns:
        True if the entity contains collections fetchable by subselect; false otherwise.
      • hasCollectionNotReferencingPK

        boolean hasCollectionNotReferencingPK()
        Determine whether this entity contains references to persistent collections not referencing the primary key.
        Returns:
        True if the entity contains a collection not referencing the primary key; false otherwise.
        Since:
        6.2
      • hasCascades

        boolean hasCascades()
        Determine whether this entity has any (non-none) cascading.
        Returns:
        True if the entity has any properties with a cascade other than NONE; false otherwise (aka, no cascading).
      • hasCascadeDelete

        default boolean hasCascadeDelete()
        Determine whether this entity has any delete cascading.
        Returns:
        True if the entity has any properties with a cascade other than NONE; false otherwise.
      • hasOwnedCollections

        default boolean hasOwnedCollections()
        Determine whether this entity has any owned collections.
        Returns:
        True if the entity has an owned collection; false otherwise.
      • isMutable

        boolean isMutable()
        Determine whether instances of this entity are considered mutable.
        Returns:
        True if the entity is considered mutable; false otherwise.
      • isInherited

        boolean isInherited()
        Determine whether the entity is inherited one or more other entities. In other words, is this entity a subclass of other entities.
        Returns:
        True if other entities extend this entity; false otherwise.
      • isIdentifierAssignedByInsert

        boolean isIdentifierAssignedByInsert()
        Are identifiers of this entity assigned known before the insert execution? Or, are they generated (in the database) by the insert execution.
        Returns:
        True if identifiers for this entity are generated by the insert execution.
      • findDirty

        int[] findDirty​(Object[] currentState,
                        Object[] previousState,
                        Object owner,
                        SharedSessionContractImplementor session)
        Compare the two snapshots to determine if they represent dirty state.
        Parameters:
        currentState - The current snapshot
        previousState - The baseline snapshot
        owner - The entity containing the state
        session - The originating session
        Returns:
        The indices of all dirty properties, or null if no properties were dirty.
      • findModified

        int[] findModified​(Object[] old,
                           Object[] current,
                           Object object,
                           SharedSessionContractImplementor session)
        Compare the two snapshots to determine if they represent modified state.
        Parameters:
        old - The baseline snapshot
        current - The current snapshot
        object - The entity containing the state
        session - The originating session
        Returns:
        The indices of all modified properties, or null if no properties were modified.
      • hasIdentifierProperty

        boolean hasIdentifierProperty()
        Determine whether the entity has a particular property holding the identifier value.
        Returns:
        True if the entity has a specific property holding identifier value.
      • canExtractIdOutOfEntity

        @Deprecated(since="6")
        default boolean canExtractIdOutOfEntity()
        Deprecated.
        This feature is no longer supported
        Determine whether detached instances of this entity carry their own identifier value.

        The other option is the deprecated feature where users could supply the id during session calls.

        Returns:
        True if either (1) hasIdentifierProperty() or (2) the identifier is an embedded composite identifier; false otherwise.
      • isVersioned

        boolean isVersioned()
        Determine whether optimistic locking by column is enabled for this entity.
        Returns:
        True if optimistic locking by column (i.e., <version/> or <timestamp/>) is enabled; false otherwise.
      • getVersionType

        BasicType<?> getVersionType()
        If isVersioned(), then what is the type of the property holding the locking value.
        Returns:
        The type of the version property; or null, if not versioned.
      • getVersionProperty

        int getVersionProperty()
        If isVersioned(), then what is the index of the property holding the locking value.
        Returns:
        The type of the version property; or -66, if not versioned.
      • hasNaturalIdentifier

        boolean hasNaturalIdentifier()
        Determine whether this entity defines a natural identifier.
        Returns:
        True if the entity defines a natural id; false otherwise.
      • getNaturalIdentifierProperties

        int[] getNaturalIdentifierProperties()
        If the entity defines a natural id, that is, if hasNaturalIdentifier() returns true, the indices of the properties which make up the natural id.
        Returns:
        The indices of the properties making up the natural id; or null, if no natural id is defined.
      • getNaturalIdentifierSnapshot

        Object getNaturalIdentifierSnapshot​(Object id,
                                            SharedSessionContractImplementor session)
        Retrieve the current state of the natural-id properties from the database.
        Parameters:
        id - The identifier of the entity for which to retrieve the natural-id values.
        session - The session from which the request originated.
        Returns:
        The natural-id snapshot.
      • getIdentifierGenerator

        @Deprecated
        IdentifierGenerator getIdentifierGenerator()
        Deprecated.
        Determine which identifier generation strategy is used for this entity.
        Returns:
        The identifier generation strategy.
      • getGenerator

        default Generator getGenerator()
      • breakDownJdbcValues

        default <X,​Y> int breakDownJdbcValues​(Object domainValue,
                                                    int offset,
                                                    X x,
                                                    Y y,
                                                    ModelPart.JdbcValueBiConsumer<X,​Y> valueConsumer,
                                                    SharedSessionContractImplementor session)
        Description copied from interface: ModelPart
        Breaks down the domain value to its constituent JDBC values. Think of it as breaking the multi-dimensional array into a visitable flat array. Additionally, it passes through the values X and Y to the consumer. Returns the amount of jdbc types that have been visited.
        Specified by:
        breakDownJdbcValues in interface ModelPart
      • hasLazyProperties

        boolean hasLazyProperties()
        Determine whether this entity defines any lazy properties (when bytecode instrumentation is enabled).
        Returns:
        True if the entity has properties mapped as lazy; false otherwise.
      • multiLoad

        List<?> multiLoad​(Object[] ids,
                          EventSource session,
                          MultiIdLoadOptions loadOptions)
        Performs a load of multiple entities (of this type) by identifier simultaneously.
        Parameters:
        ids - The identifiers to load
        session - The originating Session
        loadOptions - The options for loading
        Returns:
        The loaded, matching entities
      • getPropertyTypes

        Type[] getPropertyTypes()
        Get the Hibernate types of the class properties
      • getPropertyNames

        String[] getPropertyNames()
        Get the names of the class properties - doesn't have to be the names of the actual Java properties (used for XML generation only)
      • getPropertyInsertability

        boolean[] getPropertyInsertability()
        Get the "insertability" of the properties of this class (does the property appear in an SQL INSERT)
      • getPropertyUpdateability

        boolean[] getPropertyUpdateability()
        Get the "updateability" of the properties of this class (does the property appear in an SQL UPDATE)
      • getPropertyCheckability

        boolean[] getPropertyCheckability()
        Get the "checkability" of the properties of this class (is the property dirty checked, does the cache need to be updated)
      • getPropertyNullability

        boolean[] getPropertyNullability()
        Get the nullability of the properties of this class
      • getPropertyVersionability

        boolean[] getPropertyVersionability()
        Get the "versionability" of the properties of this class (is the property optimistic-locked)
      • getPropertyLaziness

        boolean[] getPropertyLaziness()
      • getPropertyCascadeStyles

        CascadeStyle[] getPropertyCascadeStyles()
        Get the cascade styles of the properties (optional operation)
      • isPropertySelectable

        default boolean isPropertySelectable​(int propertyNumber)
      • getIdentifierType

        Type getIdentifierType()
        Get the identifier type
      • getIdentifierPropertyName

        String getIdentifierPropertyName()
        Get the name of the identifier property (or return null) - need not return the name of an actual Java property
      • isCacheInvalidationRequired

        boolean isCacheInvalidationRequired()
        Should we always invalidate the cache instead of recaching updated state
      • isLazyPropertiesCacheable

        boolean isLazyPropertiesCacheable()
        Should lazy properties of this entity be cached?
      • canReadFromCache

        boolean canReadFromCache()
      • canWriteToCache

        boolean canWriteToCache()
      • getCacheAccessStrategy

        EntityDataAccess getCacheAccessStrategy()
        Get the cache (optional operation)
      • hasNaturalIdCache

        boolean hasNaturalIdCache()
        Does this class have a natural id cache
      • getNaturalIdCacheAccessStrategy

        NaturalIdDataAccess getNaturalIdCacheAccessStrategy()
        Get the NaturalId cache (optional operation)
      • getClassMetadata

        @Deprecated(since="6.0")
        ClassMetadata getClassMetadata()
        Deprecated.
        This operation is no longer called by Hibernate.
        Get the user-visible metadata for the class (optional operation)
      • isSelectBeforeUpdateRequired

        boolean isSelectBeforeUpdateRequired()
        Is select snapshot before update enabled?
      • isInstrumented

        boolean isInstrumented()
        Has the class actually been bytecode instrumented?
      • hasInsertGeneratedProperties

        boolean hasInsertGeneratedProperties()
        Does this entity define any properties as being database generated on insert?
        Returns:
        True if this entity contains at least one property defined as generated (including version property, but not identifier).
      • hasUpdateGeneratedProperties

        boolean hasUpdateGeneratedProperties()
        Does this entity define any properties as being database generated on update?
        Returns:
        True if this entity contains at least one property defined as generated (including version property, but not identifier).
      • isVersionPropertyGenerated

        boolean isVersionPropertyGenerated()
        Does this entity contain a version property that is defined to be database generated?
        Returns:
        true if this entity contains a version property and that property has been marked as generated.
      • processInsertGeneratedProperties

        void processInsertGeneratedProperties​(Object id,
                                              Object entity,
                                              Object[] state,
                                              SharedSessionContractImplementor session)
        Perform a select to retrieve the values of any generated properties back from the database, injecting these generated values into the given entity as well as writing this state to the PersistenceContext.

        Note, that because we update the PersistenceContext here, callers need to take care that they have already written the initial snapshot to the PersistenceContext before calling this method.

      • processUpdateGeneratedProperties

        void processUpdateGeneratedProperties​(Object id,
                                              Object entity,
                                              Object[] state,
                                              SharedSessionContractImplementor session)
        Perform a select to retrieve the values of any generated properties back from the database, injecting these generated values into the given entity as well as writing this state to the PersistenceContext.

        Note, that because we update the PersistenceContext here, callers need to take care that they have already written the initial snapshot to the PersistenceContext before calling this method.

      • getMappedClass

        Class<?> getMappedClass()
        The persistent class, or null
      • implementsLifecycle

        boolean implementsLifecycle()
        Does the class implement the Lifecycle interface?
      • getConcreteProxyClass

        Class<?> getConcreteProxyClass()
        Get the proxy interface that instances of this concrete class will be cast to (optional operation).
      • getPropertyValue

        Object getPropertyValue​(Object object,
                                String propertyName)
        Get the value of a particular property
      • getIdentifier

        Object getIdentifier​(Object entity,
                             SharedSessionContractImplementor session)
        Get the identifier of an instance from the object's identifier property. Throw an exception if it has no identifier property.
      • instantiate

        Object instantiate​(Object id,
                           SharedSessionContractImplementor session)
        Create a class instance initialized with the given identifier
        Parameters:
        id - The identifier value to use (may be null to represent no value)
        session - The session from which the request originated.
        Returns:
        The instantiated entity.
      • isInstance

        boolean isInstance​(Object object)
        Is the given object an instance of this entity?
      • hasUninitializedLazyProperties

        boolean hasUninitializedLazyProperties​(Object object)
        Does the given instance have any uninitialized lazy properties?
      • resetIdentifier

        void resetIdentifier​(Object entity,
                             Object currentId,
                             Object currentVersion,
                             SharedSessionContractImplementor session)
        Set the identifier and version of the given instance back to its "unsaved" value, that is, the value it had before it was made persistent.
      • getSubclassEntityPersister

        EntityPersister getSubclassEntityPersister​(Object instance,
                                                   SessionFactoryImplementor factory)
        Obtain the EntityPersister for the concrete class of the given entity instance which participates in a mapped inheritance hierarchy with this persister. The given instance must be an instance of a subclass of the persistent class managed by this persister.

        A request has already identified the entity name of this persister as the mapping for the given instance. However, we still need to account for possible subclassing and potentially reroute to the more appropriate persister.

        For example, a request names Animal as the entity name which gets resolved to this persister. But the actual instance is really an instance of Cat which is a subclass of Animal. So, here the Animal persister is being asked to return the persister specific to Cat.

        It's also possible that the instance is actually an Animal instance in the above example in which case we would return this from this method.

        Parameters:
        instance - The entity instance
        factory - Reference to the SessionFactory
        Returns:
        The appropriate persister
        Throws:
        HibernateException - Indicates that instance was deemed to not be a subclass of the entity mapped by this persister.
      • resolveAttributeIndexes

        int[] resolveAttributeIndexes​(String[] attributeNames)
        Converts an array of attribute names to a set of indexes, according to the entity metamodel
        Parameters:
        attributeNames - Array of names to be resolved
        Returns:
        A set of unique indexes of the attribute names found in the metamodel
      • resolveDirtyAttributeIndexes

        default int[] resolveDirtyAttributeIndexes​(Object[] values,
                                                   Object[] loadedState,
                                                   String[] attributeNames,
                                                   SessionImplementor session)
        Like resolveAttributeIndexes(String[]) but also always returns mutable attributes
        Parameters:
        attributeNames - Array of names to be resolved
        Returns:
        A set of unique indexes of the attribute names found in the metamodel
      • canUseReferenceCacheEntries

        boolean canUseReferenceCacheEntries()