Top Description Inners Fields Methods
org.hibernate.metamodel.mapping

public Interface EntityIdentifierMapping

extends ValuedModelPart
Known Direct Subinterfaces
org.hibernate.metamodel.mapping.CompositeIdentifierMapping, org.hibernate.metamodel.mapping.internal.SingleAttributeIdentifierMapping
Imports
org.hibernate.TransientObjectException, org.hibernate.engine.internal.ForeignKeys, org.hibernate.engine.spi.IdentifierValue, .SharedSessionContractImplementor, jakarta.persistence.EmbeddedId, .Id, .IdClass

Describes the mapping of an entity's identifier.
See Also
Id, EmbeddedId, Nature

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum
EntityIdentifierMapping.Nature

The style of identifier used.

Field Summary

Modifier and TypeField and Description
public static final String
public static final String

Method Summary

Modifier and TypeMethod and Description
public String
getAttributeName()

The name of the attribute defining the id, if one

public Object
getIdentifier(Object entity)

Extract the identifier from an instance of the entity

public default Object

Returns:

The identifier
getIdentifierIfNotUnsaved
(Object
The entity instance
entity
,
SharedSessionContractImplementor
The session
session
)

Return the identifier of the persistent or transient object, or throw an exception if the instance is "unsaved"

Used by OneToOneType and ManyToOneType to determine what id value should be used for an object that may or may not be associated with the session.

public EntityIdentifierMapping.Nature
public default String
getPartName()

Implements org.hibernate.metamodel.mapping.ModelPart.getPartName.

The local part name, which is generally the unqualified role name
public IdentifierValue
getUnsavedStrategy()

The strategy for distinguishing between detached and transient state based on the identifier mapping

public Object
instantiate()

Instantiate an instance of the identifier.

public default boolean
public static boolean
public void
setIdentifier(Object entity, Object id, SharedSessionContractImplementor session)

Inject an identifier value into an instance of the entity

Inherited from org.hibernate.metamodel.mapping.ValuedModelPart:
forEachInsertableforEachNonFormulaforEachSelectableforEachSelectableforEachUpdatablegetContainingTableExpressiongetJdbcTypeCountgetSingleJdbcMapping

Field Detail

ID_ROLE_NAMEback to summary
public static final String ID_ROLE_NAME
LEGACY_ID_NAMEback to summary
public static final String LEGACY_ID_NAME

Method Detail

getAttributeNameback to summary
public String getAttributeName()

The name of the attribute defining the id, if one

getIdentifierback to summary
public Object getIdentifier(Object entity)

Extract the identifier from an instance of the entity

getIdentifierIfNotUnsavedback to summary
public 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"

Used by OneToOneType and ManyToOneType to determine what id value 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).

Parameters
entity:Object

The entity instance

session:SharedSessionContractImplementor

The session

Returns:Object

The identifier

Exceptions
TransientObjectException:
if the entity is transient (does not yet have an identifier)
Since
6.1.1
See Also
org.hibernate.engine.internal.ForeignKeys#getEntityIdentifierIfNotUnsaved(String, Object, SharedSessionContractImplementor)
getNatureback to summary
public EntityIdentifierMapping.Nature getNature()
See Also
Nature
getPartNameback to summary
public default String getPartName()

Implements org.hibernate.metamodel.mapping.ModelPart.getPartName.

Doc from org.hibernate.metamodel.mapping.ModelPart.getPartName.

The local part name, which is generally the unqualified role name

Annotations
@Override
getUnsavedStrategyback to summary
public IdentifierValue getUnsavedStrategy()

The strategy for distinguishing between detached and transient state based on the identifier mapping

See Also
EntityVersionMapping#getUnsavedStrategy()
instantiateback to summary
public Object instantiate()

Instantiate an instance of the identifier.

API Note

This is really only valid on composite identifiers

isEntityIdentifierMappingback to summary
public default boolean isEntityIdentifierMapping()

Overrides default org.hibernate.metamodel.mapping.ModelPart.isEntityIdentifierMapping.

Annotations
@Override
matchesRoleNameback to summary
public static boolean matchesRoleName(String name)
setIdentifierback to summary
public void setIdentifier(Object entity, Object id, SharedSessionContractImplementor session)

Inject an identifier value into an instance of the entity

org.hibernate.metamodel.mapping back to summary

public final Enum EntityIdentifierMapping.Nature

extends Enum<EntityIdentifierMapping.Nature>
Class Inheritance

The style of identifier used.

Field Summary

Modifier and TypeField and Description
public static final EntityIdentifierMapping.Nature
COMPOSITE

An "aggregated" composite identifier, which is another way to say that the identifier is represented as an embeddable.

public static final EntityIdentifierMapping.Nature
SIMPLE

Simple, single-column identifier.

public static final EntityIdentifierMapping.Nature
VIRTUAL

Composite identifier defined with multiple Id mappings.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static EntityIdentifierMapping.Nature
public static EntityIdentifierMapping.Nature[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

COMPOSITEback to summary
public static final EntityIdentifierMapping.Nature COMPOSITE

An "aggregated" composite identifier, which is another way to say that the identifier is represented as an embeddable.

See Also
EmbeddedId, AggregatedIdentifierMapping
SIMPLEback to summary
public static final EntityIdentifierMapping.Nature SIMPLE

Simple, single-column identifier.

See Also
Id, BasicEntityIdentifierMapping
VIRTUALback to summary
public static final EntityIdentifierMapping.Nature VIRTUAL

Composite identifier defined with multiple Id mappings. Often used in conjunction with an IdClass

See Also
Id, IdClass, NonAggregatedIdentifierMapping

Constructor Detail

Natureback to summary
private Nature()

Method Detail

valueOfback to summary
public static EntityIdentifierMapping.Nature valueOf(String name)
valuesback to summary
public static EntityIdentifierMapping.Nature[] values()