Interface EntityIdentifierMapping

All Superinterfaces:
Bindable, Fetchable, JavaTypedExpressible, JdbcMappingContainer, MappingModelExpressible, ModelPart, SelectableMappings, ValuedModelPart, ValueMapping
All Known Subinterfaces:
AggregatedIdentifierMapping, BasicEntityIdentifierMapping, CompositeIdentifierMapping, NonAggregatedIdentifierMapping, org.hibernate.metamodel.mapping.internal.SingleAttributeIdentifierMapping

public interface EntityIdentifierMapping extends ValuedModelPart, Fetchable
Describes the mapping of an entity's identifier.
See Also:
  • Field Details

  • Method Details

    • matchesRoleName

      static boolean matchesRoleName(String name)
    • getPartName

      default String getPartName()
      Description copied from interface: ModelPart
      The local part name, which is generally the unqualified role name
      Specified by:
      getPartName in interface ModelPart
    • getNature

      See Also:
    • getAttributeName

      String getAttributeName()
      The name of the attribute defining the id, if one
    • getUnsavedStrategy

      IdentifierValue getUnsavedStrategy()
      The strategy for distinguishing between detached and transient state based on the identifier mapping
      See Also:
    • instantiate

      Object instantiate()
      Instantiate an instance of the identifier.
      API Note:
      This is really only valid on composite identifiers
    • getIdentifier

      Object getIdentifier(Object entity)
      Extract the identifier from an instance of the entity
    • getIdentifier

      default Object getIdentifier(Object entity, MergeContext mergeContext)
      Extract the identifier from an instance of the entity
      API Note:
      Intended for use during the merging process
    • getIdentifierIfNotUnsaved

      default Object getIdentifierIfNotUnsaved(Object entity, SharedSessionContractImplementor session)
      Return the identifier of the persistent or transient object, or throw an exception if the instance is "unsaved"
      Parameters:
      entity - The entity instance
      session - The session
      Returns:
      The identifier
      Throws:
      TransientObjectException - if the entity is transient (does not yet have an identifier)
      Since:
      6.1.1
      See Also:
      • ForeignKeys.getEntityIdentifierIfNotUnsaved(java.lang.String, java.lang.Object, org.hibernate.engine.spi.SharedSessionContractImplementor)
      API Note:
      This method is called by OneToOneType and ManyToOneType to determine the id value which should be used for an object that may or may not be associated with the session. This does a "best guess" using any/all info available to use (not just the EntityEntry).
    • setIdentifier

      void setIdentifier(Object entity, Object id, SharedSessionContractImplementor session)
      Inject an identifier value into an instance of the entity
    • isEntityIdentifierMapping

      default boolean isEntityIdentifierMapping()
      Specified by:
      isEntityIdentifierMapping in interface ModelPart