Constructors Summary |
---|
EntityEntry(Status status, Object[] loadedState, Object rowId, Serializable id, Object version, org.hibernate.LockMode lockMode, boolean existsInDatabase, org.hibernate.persister.entity.EntityPersister persister, org.hibernate.EntityMode entityMode, boolean disableVersionIncrement, boolean lazyPropertiesAreUnfetched)
this.status=status;
this.loadedState=loadedState;
this.id=id;
this.rowId=rowId;
this.existsInDatabase=existsInDatabase;
this.version=version;
this.lockMode=lockMode;
this.isBeingReplicated=disableVersionIncrement;
this.loadedWithLazyPropertiesUnfetched = lazyPropertiesAreUnfetched;
this.persister=persister;
this.entityMode = entityMode;
this.entityName = persister == null ?
null : persister.getEntityName();
|
private EntityEntry(SessionFactoryImplementor factory, String entityName, Serializable id, org.hibernate.EntityMode entityMode, Status status, Object[] loadedState, Object[] deletedState, Object version, org.hibernate.LockMode lockMode, boolean existsInDatabase, boolean isBeingReplicated, boolean loadedWithLazyPropertiesUnfetched)Used during custom deserialization
this.entityName = entityName;
this.persister = factory.getEntityPersister( entityName );
this.id = id;
this.entityMode = entityMode;
this.status = status;
this.loadedState = loadedState;
this.deletedState = deletedState;
this.version = version;
this.lockMode = lockMode;
this.existsInDatabase = existsInDatabase;
this.isBeingReplicated = isBeingReplicated;
this.loadedWithLazyPropertiesUnfetched = loadedWithLazyPropertiesUnfetched;
this.rowId = null; // this is equivalent to the old behavior...
|
Methods Summary |
---|
void | afterDeserialize(SessionFactoryImplementor factory)
persister = factory.getEntityPersister( entityName );
|
static org.hibernate.engine.EntityEntry | deserialize(java.io.ObjectInputStream ois, SessionImplementor session)Custom deserialization routine used during deserialization of a
Session/PersistenceContext for increased performance.
return new EntityEntry(
session.getFactory(),
( String ) ois.readObject(),
( Serializable ) ois.readObject(),
EntityMode.parse( ( String ) ois.readObject() ),
Status.parse( ( String ) ois.readObject() ),
( Object[] ) ois.readObject(),
( Object[] ) ois.readObject(),
( Object ) ois.readObject(),
LockMode.parse( ( String ) ois.readObject() ),
ois.readBoolean(),
ois.readBoolean(),
ois.readBoolean()
);
|
public void | forceLocked(java.lang.Object entity, java.lang.Object nextVersion)
version = nextVersion;
loadedState[ persister.getVersionProperty() ] = version;
setLockMode( LockMode.FORCE );
persister.setPropertyValue(
entity,
getPersister().getVersionProperty(),
nextVersion,
entityMode
);
|
public java.lang.Object[] | getDeletedState()
return deletedState;
|
public java.lang.String | getEntityName()
return entityName;
|
public java.io.Serializable | getId()
return id;
|
public java.lang.Object[] | getLoadedState()
return loadedState;
|
public java.lang.Object | getLoadedValue(java.lang.String propertyName)
int propertyIndex = ( (UniqueKeyLoadable) persister ).getPropertyIndex(propertyName);
return loadedState[propertyIndex];
|
public org.hibernate.LockMode | getLockMode()
return lockMode;
|
public org.hibernate.persister.entity.EntityPersister | getPersister()
return persister;
|
public java.lang.Object | getRowId()
return rowId;
|
public Status | getStatus()
return status;
|
public java.lang.Object | getVersion()
return version;
|
public boolean | isBeingReplicated()
return isBeingReplicated;
|
public boolean | isExistsInDatabase()
return existsInDatabase;
|
public boolean | isLoadedWithLazyPropertiesUnfetched()
return loadedWithLazyPropertiesUnfetched;
|
public boolean | isNullifiable(boolean earlyInsert, SessionImplementor session)
return getStatus() == Status.SAVING || (
earlyInsert ?
!isExistsInDatabase() :
session.getPersistenceContext().getNullifiableEntityKeys()
.contains( new EntityKey( getId(), getPersister(), entityMode ) )
);
|
public void | postDelete()After actually deleting a row, record the fact that the instance no longer
exists in the database
status = Status.GONE;
existsInDatabase = false;
|
public void | postInsert()After actually inserting a row, record the fact that the instance exists on the
database (needed for identity-column key generation)
existsInDatabase = true;
|
public void | postUpdate(java.lang.Object entity, java.lang.Object[] updatedState, java.lang.Object nextVersion)After actually updating the database, update the snapshot information,
and escalate the lock mode
this.loadedState = updatedState;
setLockMode(LockMode.WRITE);
if ( getPersister().isVersioned() ) {
this.version = nextVersion;
getPersister().setPropertyValue(
entity,
getPersister().getVersionProperty(),
nextVersion,
entityMode
);
}
FieldInterceptionHelper.clearDirty( entity );
|
public boolean | requiresDirtyCheck(java.lang.Object entity)
boolean isMutableInstance =
status != Status.READ_ONLY &&
persister.isMutable();
return isMutableInstance && (
getPersister().hasMutableProperties() ||
!FieldInterceptionHelper.isInstrumented( entity ) ||
FieldInterceptionHelper.extractFieldInterceptor( entity).isDirty()
);
|
void | serialize(java.io.ObjectOutputStream oos)Custom serialization routine used during serialization of a
Session/PersistenceContext for increased performance.
oos.writeObject( entityName );
oos.writeObject( id );
oos.writeObject( entityMode.toString() );
oos.writeObject( status.toString() );
// todo : potentially look at optimizing these two arrays
oos.writeObject( loadedState );
oos.writeObject( deletedState );
oos.writeObject( version );
oos.writeObject( lockMode.toString() );
oos.writeBoolean( existsInDatabase );
oos.writeBoolean( isBeingReplicated );
oos.writeBoolean( loadedWithLazyPropertiesUnfetched );
|
public void | setDeletedState(java.lang.Object[] deletedState)
this.deletedState = deletedState;
|
public void | setLockMode(org.hibernate.LockMode lockMode)
this.lockMode = lockMode;
|
public void | setReadOnly(boolean readOnly, java.lang.Object entity)
if (status!=Status.MANAGED && status!=Status.READ_ONLY) {
throw new HibernateException("instance was not in a valid state");
}
if (readOnly) {
setStatus(Status.READ_ONLY);
loadedState = null;
}
else {
setStatus(Status.MANAGED);
loadedState = getPersister().getPropertyValues(entity, entityMode);
}
|
public void | setStatus(Status status)
if (status==Status.READ_ONLY) {
loadedState = null; //memory optimization
}
this.status = status;
|
public java.lang.String | toString()
return "EntityEntry" +
MessageHelper.infoString(entityName, id) +
'(" + status + ')";
|