EntityKeypublic final class EntityKey extends Object implements SerializableUniquely identifies of an entity instance in a particular session by identifier.
Uniqueing information consists of the entity-name and the identifier value. |
Fields Summary |
---|
private final Serializable | identifier | private final String | rootEntityName | private final String | entityName | private final org.hibernate.type.Type | identifierType | private final boolean | isBatchLoadable | private final SessionFactoryImplementor | factory | private final int | hashCode | private final org.hibernate.EntityMode | entityMode |
Constructors Summary |
---|
public EntityKey(Serializable id, org.hibernate.persister.entity.EntityPersister persister, org.hibernate.EntityMode entityMode)Construct a unique identifier for an entity class instance
if ( id == null ) {
throw new AssertionFailure( "null identifier" );
}
this.identifier = id;
this.entityMode = entityMode;
this.rootEntityName = persister.getRootEntityName();
this.entityName = persister.getEntityName();
this.identifierType = persister.getIdentifierType();
this.isBatchLoadable = persister.isBatchLoadable();
this.factory = persister.getFactory();
hashCode = generateHashCode(); //cache the hashcode
| private EntityKey(Serializable identifier, String rootEntityName, String entityName, org.hibernate.type.Type identifierType, boolean batchLoadable, SessionFactoryImplementor factory, org.hibernate.EntityMode entityMode)Used to reconstruct an EntityKey during deserialization.
this.identifier = identifier;
this.rootEntityName = rootEntityName;
this.entityName = entityName;
this.identifierType = identifierType;
this.isBatchLoadable = batchLoadable;
this.factory = factory;
this.entityMode = entityMode;
this.hashCode = generateHashCode();
|
Methods Summary |
---|
static org.hibernate.engine.EntityKey | deserialize(java.io.ObjectInputStream ois, SessionImplementor session)Custom deserialization routine used during deserialization of a
Session/PersistenceContext for increased performance.
return new EntityKey(
( Serializable ) ois.readObject(),
( String ) ois.readObject(),
( String ) ois.readObject(),
( Type ) ois.readObject(),
ois.readBoolean(),
session.getFactory(),
EntityMode.parse( ( String ) ois.readObject() )
);
| public boolean | equals(java.lang.Object other)
EntityKey otherKey = (EntityKey) other;
return otherKey.rootEntityName.equals(this.rootEntityName) &&
identifierType.isEqual(otherKey.identifier, this.identifier, entityMode, factory);
| private int | generateHashCode()
int result = 17;
result = 37 * result + rootEntityName.hashCode();
result = 37 * result + identifierType.getHashCode( identifier, entityMode, factory );
return result;
| public java.lang.String | getEntityName()
return entityName;
| public java.io.Serializable | getIdentifier()Get the user-visible identifier
return identifier;
| public int | hashCode()
return hashCode;
| public boolean | isBatchLoadable()
return isBatchLoadable;
| void | serialize(java.io.ObjectOutputStream oos)Custom serialization routine used during serialization of a
Session/PersistenceContext for increased performance.
oos.writeObject( identifier );
oos.writeObject( rootEntityName );
oos.writeObject( entityName );
oos.writeObject( identifierType );
oos.writeBoolean( isBatchLoadable );
oos.writeObject( entityMode.toString() );
| public java.lang.String | toString()
return "EntityKey" +
MessageHelper.infoString( factory.getEntityPersister( entityName ), identifier, factory );
|
|