Package org.hibernate.engine.spi
Class EntityKey
- java.lang.Object
-
- org.hibernate.engine.spi.EntityKey
-
- All Implemented Interfaces:
Serializable
public final class EntityKey extends Object implements Serializable
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(java.lang.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.
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description EntityKey(@Nullable Object id, EntityPersister persister)
Construct a unique identifier for an entity class instance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static EntityKey
deserialize(ObjectInputStream ois, SessionFactoryImplementor sessionFactory)
Custom deserialization routine used during deserialization of a Session/PersistenceContext for increased performance.boolean
equals(@Nullable Object other)
String
getEntityName()
Object
getIdentifier()
Object
getIdentifierValue()
EntityPersister
getPersister()
int
hashCode()
boolean
isBatchLoadable(LoadQueryInfluencers influencers)
void
serialize(ObjectOutputStream oos)
Custom serialization routine used during serialization of a Session/PersistenceContext for increased performance.String
toString()
-
-
-
Constructor Detail
-
EntityKey
public EntityKey(@Nullable Object id, EntityPersister persister)
Construct a unique identifier for an entity class instance.- Parameters:
id
- The entity idpersister
- The entity persister- API Note:
- This signature has changed to accommodate both entity mode and multi-tenancy, both of which relate to
the session to which this key belongs. To help minimize the impact of these changes in the future, the
SharedSessionContractImplementor.generateEntityKey(java.lang.Object, org.hibernate.persister.entity.EntityPersister)
method was added to hide the session-specific changes.
-
-
Method Detail
-
isBatchLoadable
public boolean isBatchLoadable(LoadQueryInfluencers influencers)
-
getIdentifierValue
public Object getIdentifierValue()
-
getIdentifier
public Object getIdentifier()
-
getEntityName
public String getEntityName()
-
getPersister
public EntityPersister getPersister()
-
serialize
public void serialize(ObjectOutputStream oos) throws IOException
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 EntityEntry
- Throws:
IOException
- Thrown by Java I/OClassNotFoundException
- Thrown by Java I/O
-
-