Class EntityKey
java.lang.Object
org.hibernate.engine.spi.EntityKey
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
TemporalEntityKey
Uniquely identifies of an entity instance in a particular Session by identifier.
Note that it's only safe to be used within the scope of a Session: it doesn't consider for example the tenantId
as part of the equality definition.
Information used to determine uniqueness consists of the entity-name and the identifier value (see equals(Object)).
Performance considerations: lots of instances of this type are created at runtime. Make sure each one is as small as possible by storing just the essential needed.
For temporal entities, use TemporalEntityKey which includes a changeset identifier
to isolate historical snapshots in the persistence context.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionEntityKey(@Nullable Object id, EntityPersister persister) Construct a unique identifier for an entity class instance. -
Method Summary
Modifier and TypeMethodDescriptionstatic EntityKeydeserialize(ObjectInputStream ois, SessionFactoryImplementor sessionFactory) Custom deserialization routine used during deserialization of a Session/PersistenceContext for increased performance.boolean@Nullable ObjectThe audit changeset identifier for this key, ornullfor non-temporal entities.inthashCode()booleanisBatchLoadable(LoadQueryInfluencers influencers) booleanWhether this key refers to a temporal (historical) snapshot.voidCustom serialization routine used during serialization of a Session/PersistenceContext for increased performance.toString()
-
Constructor Details
-
EntityKey
Construct a unique identifier for an entity class instance.For temporal (audit) contexts, prefer
SharedSessionContractImplementor.generateEntityKey(Object, EntityPersister)which automatically creates aTemporalEntityKeywhen operating in a temporal context.- Parameters:
id- The entity idpersister- The entity persister
-
-
Method Details
-
isBatchLoadable
-
getIdentifierValue
-
getIdentifier
-
getEntityName
-
getPersister
-
getChangesetId
The audit changeset identifier for this key, ornullfor non-temporal entities. When non-null, this entity is a read-only historical snapshot. -
isTemporal
public boolean isTemporal()Whether this key refers to a temporal (historical) snapshot. -
equals
-
hashCode
-
toString
-
serialize
Custom serialization routine used during serialization of a Session/PersistenceContext for increased performance.- Parameters:
oos- The stream to which we should write the serial data.- Throws:
IOException- Thrown by Java I/O
-
deserialize
public static EntityKey deserialize(ObjectInputStream ois, SessionFactoryImplementor sessionFactory) throws IOException, ClassNotFoundException Custom deserialization routine used during deserialization of a Session/PersistenceContext for increased performance.- Parameters:
ois- The stream from which to read the entry.sessionFactory- The SessionFactory owning the Session being deserialized.- Returns:
- The deserialized EntityKey
- Throws:
IOException- Thrown by Java I/OClassNotFoundException- Thrown by Java I/O
-