Interface EntityPersister

All Superinterfaces:
AttributeSource, Bindable, Discriminable, EntityMappingType, EntityMutationTarget, EntityValuedModelPart, FetchableContainer, FilterRestrictable, JdbcMappingContainer, Loadable, ManagedMappingType, MappingModelExpressible, MappingType, ModelPart, ModelPartContainer, MutationTarget<EntityTableMapping>, Restrictable, RootTableGroupProducer, SoftDeletableModelPart, TableGroupProducer, WhereRestrictable
All Known Implementing Classes:
AbstractEntityPersister, JoinedSubclassEntityPersister, SingleTableEntityPersister, UnionSubclassEntityPersister

A strategy for persisting a mapped entity class. An EntityPersister orchestrates rendering of the SQL statements corresponding to basic lifecycle events, including insert, update, and delete statements, and their execution via JDBC.

Concrete implementations of this interface handle the single table, joined, and union inheritance mapping strategies, and to a certain extent abstract the details of those mappings from collaborators.

This interface defines a contract between the persistence strategy and the session. It does not define operations that are required for querying, nor for loading by outer join.

Unless a custom PersisterFactory is used, it is expected that implementations of EntityPersister define a constructor accepting the following arguments:

  1. PersistentClass - describes the metadata about the entity to be handled by the persister
  2. EntityDataAccess - the second level caching strategy for this entity
  3. NaturalIdDataAccess - the second level caching strategy for any natural id defined for this entity
  4. RuntimeModelCreationContext - access to additional information useful while constructing the persister.
Implementations must be thread-safe (and preferably immutable).
See Also:
  • Field Details

  • Method Details

    • postInstantiate

      void postInstantiate() throws MappingException
      Finish the initialization of this object.

      The method InFlightEntityMappingType.prepareMappingModel(org.hibernate.metamodel.mapping.internal.MappingModelCreationProcess) must have been called for every entity persister before this method is invoked.

      Called only once per SessionFactory lifecycle, after all entity persisters have been instantiated.

      Throws:
      MappingException - Indicates an issue in the metadata.
    • prepareLoaders

      default void prepareLoaders()
      Prepare loaders associated with the persister. Distinct "phase" in building the persister after InFlightEntityMappingType.prepareMappingModel(org.hibernate.metamodel.mapping.internal.MappingModelCreationProcess) and postInstantiate() have occurred.

      The distinct phase is used to ensure that all TableDetails are available across the entire model

    • getFactory

      Return the SessionFactory to which this persister belongs.
      Returns:
      The owning SessionFactory.
    • getSqlAliasStem

      default String getSqlAliasStem()
      Description copied from interface: TableGroupProducer
      Get the "stem" used as the base for generating SQL table aliases for table references that are part of the TableGroup being generated

      Note that this is a metadata-ive value. It is only ever used internal to the producer producing its TableGroup.

      Specified by:
      getSqlAliasStem in interface EntityMappingType
      Specified by:
      getSqlAliasStem in interface TableGroupProducer
      See Also:
    • 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.
    • getJpaEntityName

      @Nullable String getJpaEntityName()
      The JPA entity name, if one, associated with the entity.
    • getImportedName

      default String getImportedName()
      Specified by:
      getImportedName in interface EntityMappingType
    • getSqmMultiTableMutationStrategy

      SqmMultiTableMutationStrategy getSqmMultiTableMutationStrategy()
      The strategy to use for SQM mutation statements where the target entity has multiple tables. Returns null to indicate that the entity does not have multiple tables.
      Specified by:
      getSqmMultiTableMutationStrategy in interface EntityMappingType
    • getSqmMultiTableInsertStrategy

      SqmMultiTableInsertStrategy getSqmMultiTableInsertStrategy()
      Specified by:
      getSqmMultiTableInsertStrategy in interface EntityMappingType
    • getEntityMetamodel

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

      default Object initializeEnhancedEntityUsedAsProxy(Object entity, String nameOfAttributeBeingAccessed, SharedSessionContractImplementor session)
      Called from EnhancementAsProxyLazinessInterceptor to trigger load of the entity's non-lazy state as well as the named attribute we are accessing if it is still uninitialized after fetching non-lazy state.
    • 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

      @Deprecated(since="7.0", forRemoval=true) default String[] getSynchronizationSpaces()
      Deprecated, for removal: This API element is subject to removal in a future version.
      No longer called
      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.
    • visitQuerySpaces

      default void visitQuerySpaces(Consumer<String> querySpaceConsumer)
      Description copied from interface: EntityMappingType
      Visit each "query space" for the mapped entity.
      Specified by:
      visitQuerySpaces in interface EntityMappingType
    • 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.
    • getPropertyType

      @Deprecated(since="6", forRemoval=true) Type getPropertyType(String propertyName) throws MappingException
      Deprecated, for removal: This API element is subject to removal in a future version.
      Get the type of a particular property by name.
      Parameters:
      propertyName - The name of the property for which to retrieve the type.
      Returns:
      The type.
      Throws:
      MappingException - Typically indicates an unknown property name.
    • 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.
    • getVersionJavaType

      default VersionJavaType<Object> getVersionJavaType()
    • 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()
    • getVersionGenerator

      default BeforeExecutionGenerator getVersionGenerator()
    • getAttributeMapping

      default AttributeMapping getAttributeMapping(int position)
      Description copied from interface: EntityMappingType
      Retrieve an attribute mapping by position, relative to all attributes
      Specified by:
      getAttributeMapping in interface EntityMappingType
      Specified by:
      getAttributeMapping in interface ManagedMappingType
    • 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.
    • getNaturalIdLoader

      default NaturalIdLoader<?> getNaturalIdLoader()
      Description copied from interface: EntityMappingType
      Access to performing natural-id database selection. This is per-entity in the hierarchy
      Specified by:
      getNaturalIdLoader in interface EntityMappingType
    • getMultiNaturalIdLoader

      default MultiNaturalIdLoader<?> getMultiNaturalIdLoader()
      Description copied from interface: EntityMappingType
      Access to performing multi-value natural-id database selection. This is per-entity in the hierarchy
      Specified by:
      getMultiNaturalIdLoader in interface EntityMappingType
    • loadEntityIdByNaturalId

      Object loadEntityIdByNaturalId(Object[] naturalIdValues, LockOptions lockOptions, SharedSessionContractImplementor session)
      Load the id for the entity based on the natural id.
    • load

      Object load(Object id, Object optionalObject, LockMode lockMode, SharedSessionContractImplementor session)
      Load an instance of the persistent class.
    • load

      @Deprecated(since="6.0") default Object load(Object id, Object optionalObject, LockMode lockMode, SharedSessionContractImplementor session, Boolean readOnly) throws HibernateException
      Throws:
      HibernateException
    • load

      Object load(Object id, Object optionalObject, LockOptions lockOptions, SharedSessionContractImplementor session)
      Load an instance of the persistent class.
    • load

      default Object load(Object id, Object optionalObject, LockOptions lockOptions, SharedSessionContractImplementor session, Boolean readOnly) throws HibernateException
      Throws:
      HibernateException
    • 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
    • loadByUniqueKey

      default Object loadByUniqueKey(String propertyName, Object uniqueKey, SharedSessionContractImplementor session)
      Description copied from interface: EntityMappingType
      Load an instance of the persistent class, by a unique key other than the primary key.
      Specified by:
      loadByUniqueKey in interface EntityMappingType
    • lock

      void lock(Object id, Object version, Object object, LockMode lockMode, EventSource session)
      Do a version check (optional operation)
    • lock

      void lock(Object id, Object version, Object object, LockOptions lockOptions, EventSource session)
      Do a version check (optional operation)
    • insert

      @Deprecated(forRemoval=true, since="6.5") default void insert(Object id, Object[] fields, Object object, SharedSessionContractImplementor session)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Persist an instance
      See Also:
    • insert

      @Deprecated(forRemoval=true, since="6.5") default Object insert(Object[] fields, Object object, SharedSessionContractImplementor session)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Persist an instance
      See Also:
    • delete

      @Deprecated(forRemoval=true, since="6.5") default void delete(Object id, Object version, Object object, SharedSessionContractImplementor session)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Delete a persistent instance
      See Also:
    • update

      @Deprecated(forRemoval=true, since="6.5") default void update(Object id, Object[] fields, int[] dirtyFields, boolean hasDirtyCollection, Object[] oldFields, Object oldVersion, Object object, Object rowId, SharedSessionContractImplementor session)
      Update a persistent instance
      See Also:
    • merge

      @Deprecated(forRemoval=true, since="6.5") default void merge(Object id, Object[] fields, int[] dirtyFields, boolean hasDirtyCollection, Object[] oldFields, Object oldVersion, Object object, Object rowId, SharedSessionContractImplementor session)
      Merge a persistent instance
      See Also:
    • getInsertCoordinator

      InsertCoordinator getInsertCoordinator()
      Get the insert coordinator instance.
      Since:
      6.5
    • getUpdateCoordinator

      UpdateCoordinator getUpdateCoordinator()
      Get the update coordinator instance.
      Since:
      6.5
    • getDeleteCoordinator

      DeleteCoordinator getDeleteCoordinator()
      Get the delete coordinator instance.
      Since:
      6.5
    • getMergeCoordinator

      default UpdateCoordinator getMergeCoordinator()
      Get the merge coordinator instance.
      Since:
      6.5
    • 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()
    • getNonLazyPropertyUpdateability

      boolean[] getNonLazyPropertyUpdateability()
    • 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()
    • hasCache

      @Deprecated boolean hasCache()
      Deprecated.
      Use canReadFromCache() and/or canWriteToCache() depending on need
      Does this class have a cache.
    • getCacheAccessStrategy

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

      CacheEntryStructure getCacheEntryStructure()
      Get the cache structure
    • buildCacheEntry

      CacheEntry buildCacheEntry(Object entity, Object[] state, Object version, SharedSessionContractImplementor session)
    • hasNaturalIdCache

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

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

      default int getBatchSize()
      The batch size for batch loading.
      Specified by:
      getBatchSize in interface Loadable
      See Also:
    • isBatchLoadable

      default boolean isBatchLoadable()
      Is batch loading enabled?
      See Also:
    • isSelectBeforeUpdateRequired

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

      Object[] getDatabaseSnapshot(Object id, SharedSessionContractImplementor session) throws HibernateException
      Get the current database state of the object, in a "hydrated" form, without resolving identifiers.
      Returns:
      null if there is no row in the database
      Throws:
      HibernateException
    • getIdByUniqueKey

      Object getIdByUniqueKey(Object key, String uniquePropertyName, SharedSessionContractImplementor session)
    • getCurrentVersion

      Object getCurrentVersion(Object id, SharedSessionContractImplementor session) throws HibernateException
      Get the current version of the object, or return null if there is no row for the given identifier. In the case of unversioned data, return any object if the row exists.
      Throws:
      HibernateException
    • forceVersionIncrement

      Object forceVersionIncrement(Object id, Object currentVersion, SharedSessionContractImplementor session) throws HibernateException
      Throws:
      HibernateException
    • forceVersionIncrement

      default Object forceVersionIncrement(Object id, Object currentVersion, boolean batching, SharedSessionContractImplementor session) throws HibernateException
      Throws:
      HibernateException
    • 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.
    • afterInitialize

      void afterInitialize(Object entity, SharedSessionContractImplementor session)
      Called just after the entities properties have been initialized
    • afterReassociate

      void afterReassociate(Object entity, SharedSessionContractImplementor session)
      Called just after the entity has been reassociated with the session
    • createProxy

      Object createProxy(Object id, SharedSessionContractImplementor session)
      Create a new proxy instance
    • isTransient

      Boolean isTransient(Object object, SharedSessionContractImplementor session)
      Is this a new transient instance?
    • getPropertyValuesToInsert

      Object[] getPropertyValuesToInsert(Object object, Map<Object,Object> mergeMap, SharedSessionContractImplementor session)
      Return the values of the insertable properties of the object (including backrefs)
    • processInsertGeneratedProperties

      @Deprecated(forRemoval=true, since="6.5") default void processInsertGeneratedProperties(Object id, Object entity, Object[] state, SharedSessionContractImplementor session)
      Deprecated, for removal: This API element is subject to removal in a future version.
      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.

    • processInsertGeneratedProperties

      default void processInsertGeneratedProperties(Object id, Object entity, Object[] state, GeneratedValues generatedValues, SharedSessionContractImplementor session)
      Retrieve the values of any insert generated properties through the provided GeneratedValues or, when that's not available, by selecting them 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.

    • getGeneratedProperties

      default List<? extends ModelPart> getGeneratedProperties(EventType timing)
    • getInsertGeneratedProperties

      default List<? extends ModelPart> getInsertGeneratedProperties()
    • processUpdateGeneratedProperties

      @Deprecated(forRemoval=true, since="6.5") default void processUpdateGeneratedProperties(Object id, Object entity, Object[] state, SharedSessionContractImplementor session)
      Deprecated, for removal: This API element is subject to removal in a future version.
      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, GeneratedValues generatedValues, SharedSessionContractImplementor session)
      Retrieve the values of any update generated properties through the provided GeneratedValues or, when that's not available, by selecting them 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.

    • getUpdateGeneratedProperties

      default List<? extends ModelPart> getUpdateGeneratedProperties()
    • getMappedClass

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

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

      default void setValues(Object object, Object[] values)
      Description copied from interface: ManagedMappingType
      Inject the attribute values into the entity instance
      Specified by:
      setValues in interface ManagedMappingType
    • setPropertyValues

      @Deprecated(since="6.0") void setPropertyValues(Object object, Object[] values)
      Set the given values to the mapped properties of the given object.
    • setValue

      default void setValue(Object object, int i, Object value)
      Description copied from interface: ManagedMappingType
      Inject a specific attribute value into the entity instance, by position
      Specified by:
      setValue in interface ManagedMappingType
    • setPropertyValue

      @Deprecated(since="6.0") void setPropertyValue(Object object, int i, Object value)
      Set the value of a particular property of the given instance.
    • getValues

      default Object[] getValues(Object object)
      Description copied from interface: ManagedMappingType
      Extract the individual attribute values from the entity instance
      Specified by:
      getValues in interface ManagedMappingType
    • getPropertyValues

      @Deprecated(since="6.0") Object[] getPropertyValues(Object object)
      Deprecated.
    • getValue

      default Object getValue(Object object, int i)
      Description copied from interface: ManagedMappingType
      Extract a specific attribute value from the entity instance, by position
      Specified by:
      getValue in interface ManagedMappingType
    • getPropertyValue

      @Deprecated(since="6.0") Object getPropertyValue(Object object, int i) throws HibernateException
      Deprecated.
      Throws:
      HibernateException
    • 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.
    • getIdentifier

      default Object getIdentifier(Object entity, MergeContext mergeContext)
      Get the identifier of an instance from the object's identifier property. Throw an exception if it has no identifier property. It's supposed to be use during the merging process
    • getIdentifier

      default Object getIdentifier(Object entity)
      Get the identifier of an instance from the object's identifier property. Throw an exception if it has no identifier property.
    • setIdentifier

      void setIdentifier(Object entity, Object id, SharedSessionContractImplementor session)
      Inject the identifier value into the given entity.
    • getVersion

      Object getVersion(Object object) throws HibernateException
      Get the version number (or timestamp) from the object's version property. Return null if it is not versioned.
      Throws:
      HibernateException
    • 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.
      See Also:
    • 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.
    • getRepresentationStrategy

      EntityRepresentationStrategy getRepresentationStrategy()
      Description copied from interface: EntityMappingType
      Describes how the entity is represented in the application's domain model.
      Specified by:
      getRepresentationStrategy in interface EntityMappingType
    • getEntityMappingType

      default EntityMappingType getEntityMappingType()
      Description copied from interface: EntityValuedModelPart
      The descriptor of the entity that is the type for this part
      Specified by:
      getEntityMappingType in interface EntityValuedModelPart
    • addToCacheKey

      default void addToCacheKey(MutableCacheKeyBuilder cacheKey, Object value, SharedSessionContractImplementor session)
      Description copied from interface: Bindable
      Add to the MutableCacheKey the values obtained disassembling the value and the hasCode generated from the disassembled value.
      Specified by:
      addToCacheKey in interface Bindable
      Specified by:
      addToCacheKey in interface EntityValuedModelPart
      Parameters:
      cacheKey - the MutableCacheKey used to add the disassembled value and the hashCode
      value - the value to disassemble
      session - the SharedSessionContractImplementor
    • getInstrumentationMetadata

      BytecodeEnhancementMetadata getInstrumentationMetadata()
    • getBytecodeEnhancementMetadata

      default BytecodeEnhancementMetadata getBytecodeEnhancementMetadata()
    • getFilterAliasGenerator

      FilterAliasGenerator getFilterAliasGenerator(String rootAlias)
    • getFilterAliasGenerator

      default FilterAliasGenerator getFilterAliasGenerator(TableGroup rootTableGroup)
    • getTableName

      String getTableName()
      The table to join to.
    • 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()
    • useShallowQueryCacheLayout

      @Incubating boolean useShallowQueryCacheLayout()
    • storeDiscriminatorInShallowQueryCacheLayout

      @Incubating boolean storeDiscriminatorInShallowQueryCacheLayout()
    • hasFilterForLoadByKey

      boolean hasFilterForLoadByKey()
    • uniqueKeyEntries

      @Incubating Iterable<UniqueKeyEntry> uniqueKeyEntries()
      Returns:
      Metadata for each unique key defined
    • getSelectByUniqueKeyString

      String getSelectByUniqueKeyString(String propertyName)
      Get a SQL select string that performs a select based on a unique key determined by the given property name.
      Parameters:
      propertyName - The name of the property which maps to the column(s) to use in the select statement restriction.
      Returns:
      The SQL select string
    • getSelectByUniqueKeyString

      default String getSelectByUniqueKeyString(String[] propertyNames)
      Get a SQL select string that performs a select based on a unique key determined by the given property names.
      Parameters:
      propertyNames - The names of the properties which maps to the column(s) to use in the select statement restriction.
      Returns:
      The SQL select string
    • getSelectByUniqueKeyString

      String getSelectByUniqueKeyString(String[] propertyNames, String[] columnNames)
    • getRootTableKeyColumnNames

      String[] getRootTableKeyColumnNames()
      The names of the primary key columns in the root table.
      Returns:
      The primary key column names.
    • getIdentitySelectString

      String getIdentitySelectString()
      Get the database-specific SQL command to retrieve the last generated IDENTITY value.
      Returns:
      The SQL command string
    • getIdentifierColumnNames

      String[] getIdentifierColumnNames()
      Get the names of columns used to persist the identifier
    • getIdentifierAliases

      String[] getIdentifierAliases(String suffix)
      Get the result set aliases used for the identifier columns, given a suffix
    • getRootTableName

      String getRootTableName()
      Locks are always applied to the "root table".
      Returns:
      The root table name
    • getRootTableIdentifierColumnNames

      String[] getRootTableIdentifierColumnNames()
      Get the names of columns on the root table used to persist the identifier.
      Returns:
      The root table identifier column names.
    • getVersionColumnName

      String getVersionColumnName()
      For versioned entities, get the name of the column (again, expected on the root table) used to store the version values.
      Returns:
      The version column name.
    • getPropertyAliases

      String[] getPropertyAliases(String suffix, int i)
      Get the result set aliases used for the property columns, given a suffix (properties of this class, only).
    • getDiscriminatorAlias

      String getDiscriminatorAlias(String suffix)
      Get the result set aliases used for the identifier columns, given a suffix
    • hasMultipleTables

      boolean hasMultipleTables()
    • getTableNames

      String[] getTableNames()
    • getTableName

      @Deprecated(since="6.2") String getTableName(int j)
      Deprecated.
      Only ever used from places where we really want to use
    • getKeyColumns

      String[] getKeyColumns(int j)
    • getTableSpan

      int getTableSpan()
    • isInverseTable

      boolean isInverseTable(int j)
    • isNullableTable

      boolean isNullableTable(int j)
    • hasDuplicateTables

      boolean hasDuplicateTables()
    • getSubclassTableSpan

      int getSubclassTableSpan()
    • getSubclassTableName

      String getSubclassTableName(int j)
    • getTableNameForColumn

      String getTableNameForColumn(String columnName)
    • getDiscriminatorColumnName

      @Deprecated String getDiscriminatorColumnName()
      Returns:
      the column name for the discriminator as specified in the mapping.
    • getDiscriminatorType

      Type getDiscriminatorType()
      Get the discriminator type
    • hasRowId

      boolean hasRowId()
      Does the result set contain rowids?
    • getSubclassPropertyColumnNames

      String[] getSubclassPropertyColumnNames(int i)
    • getSubclassPropertyColumnAliases

      String[] getSubclassPropertyColumnAliases(String propertyName, String suffix)
      Return the column alias names used to persist/query the named property of the class or a subclass (optional operation).
    • countSubclassProperties

      int countSubclassProperties()
    • getPropertyColumnNames

      String[] getPropertyColumnNames(String propertyPath)
      Get the column names for the given property path
    • selectFragment

      String selectFragment(String alias, String suffix)
      All columns to select, when loading.
    • getTypeDiscriminatorMetadata

      DiscriminatorMetadata getTypeDiscriminatorMetadata()
      Retrieve the information needed to properly deal with this entity's discriminator in a query.
      Returns:
      The entity discriminator metadata
    • toColumns

      @Deprecated(since="7.0", forRemoval=true) String[] toColumns(String propertyName)
      Deprecated, for removal: This API element is subject to removal in a future version.
      No longer used in ORM core
      Given a property path, return the corresponding column name(s).
    • isSharedColumn

      boolean isSharedColumn(String columnExpression)
    • getConstraintOrderedTableKeyColumnClosure

      String[][] getConstraintOrderedTableKeyColumnClosure()
    • managesColumns

      @Internal boolean managesColumns(String[] columnNames)