Package org.hibernate.engine.spi
Interface EntityEntry
-
public interface EntityEntryWe need an entry to tell us all about the current state of an object with respect to its persistent state Implementation Warning: Hibernate needs to instantiate a high amount of instances of this class, therefore we need to take care of its impact on memory consumption.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidaddExtraState(EntityEntryExtraState extraState)voidforceLocked(Object entity, Object nextVersion)Object[]getDeletedState()EntityKeygetEntityKey()Get the EntityKey based on this EntityEntry.StringgetEntityName()<T extends EntityEntryExtraState>
TgetExtraState(Class<T> extraStateType)SerializablegetId()Object[]getLoadedState()ObjectgetLoadedValue(String propertyName)LockModegetLockMode()EntityPersistergetPersister()ObjectgetRowId()StatusgetStatus()ObjectgetVersion()booleanisBeingReplicated()booleanisExistsInDatabase()booleanisModifiableEntity()Can the entity be modified? The entity is modifiable if all of the following are true: the entity class is mutable the entity is not read-only if the current status is Status.DELETED, then the entity was not read-only when it was deletedbooleanisNullifiable(boolean earlyInsert, SharedSessionContractImplementor session)booleanisReadOnly()voidoverwriteLoadedStateCollectionValue(String propertyName, PersistentCollection collection)voidpostDelete()After actually deleting a row, record the fact that the instance no longer exists in the databasevoidpostInsert(Object[] insertedState)After actually inserting a row, record the fact that the instance exists on the database (needed for identity-column key generation)voidpostUpdate(Object entity, Object[] updatedState, Object nextVersion)Handle updating the internal state of the entry after actually performing the database update.booleanrequiresDirtyCheck(Object entity)Not sure this is the best method name, but the general idea here is to returntrueif the entity can possibly be dirty.voidserialize(ObjectOutputStream oos)Custom serialization routine used during serialization of a Session/PersistenceContext for increased performance.voidsetDeletedState(Object[] deletedState)voidsetLockMode(LockMode lockMode)voidsetReadOnly(boolean readOnly, Object entity)voidsetStatus(Status status)StringtoString()
-
-
-
Method Detail
-
getLockMode
LockMode getLockMode()
-
setLockMode
void setLockMode(LockMode lockMode)
-
getStatus
Status getStatus()
-
setStatus
void setStatus(Status status)
-
getId
Serializable getId()
-
getLoadedState
Object[] getLoadedState()
-
overwriteLoadedStateCollectionValue
void overwriteLoadedStateCollectionValue(String propertyName, PersistentCollection collection)
-
getDeletedState
Object[] getDeletedState()
-
setDeletedState
void setDeletedState(Object[] deletedState)
-
isExistsInDatabase
boolean isExistsInDatabase()
-
getVersion
Object getVersion()
-
getPersister
EntityPersister getPersister()
-
getEntityKey
EntityKey getEntityKey()
Get the EntityKey based on this EntityEntry.- Returns:
- the EntityKey
- Throws:
IllegalStateException- if getId() is null
-
getEntityName
String getEntityName()
-
isBeingReplicated
boolean isBeingReplicated()
-
getRowId
Object getRowId()
-
postUpdate
void postUpdate(Object entity, Object[] updatedState, Object nextVersion)
Handle updating the internal state of the entry after actually performing the database update. Specifically we update the snapshot information and escalate the lock mode- Parameters:
entity- The entity instanceupdatedState- The state calculated after the update (becomes the newloaded state.nextVersion- The new version.
-
postDelete
void postDelete()
After actually deleting a row, record the fact that the instance no longer exists in the database
-
postInsert
void postInsert(Object[] insertedState)
After actually inserting a row, record the fact that the instance exists on the database (needed for identity-column key generation)
-
isNullifiable
boolean isNullifiable(boolean earlyInsert, SharedSessionContractImplementor session)
-
requiresDirtyCheck
boolean requiresDirtyCheck(Object entity)
Not sure this is the best method name, but the general idea here is to returntrueif the entity can possibly be dirty. This can only be the case if it is in a modifiable state (not read-only/deleted) and it either has mutable properties or field-interception is not telling us it is dirty. Clear as mud? :/ A name like canPossiblyBeDirty might be better- Parameters:
entity- The entity to test- Returns:
trueindicates that the entity could possibly be dirty and that dirty check should happen;falseindicates there is no way the entity can be dirty
-
isModifiableEntity
boolean isModifiableEntity()
Can the entity be modified? The entity is modifiable if all of the following are true:- the entity class is mutable
- the entity is not read-only
- if the current status is Status.DELETED, then the entity was not read-only when it was deleted
- Returns:
- true, if the entity is modifiable; false, otherwise,
-
isReadOnly
boolean isReadOnly()
-
setReadOnly
void setReadOnly(boolean readOnly, Object entity)
-
serialize
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- If a stream error occurs
-
addExtraState
void addExtraState(EntityEntryExtraState extraState)
-
getExtraState
<T extends EntityEntryExtraState> T getExtraState(Class<T> extraStateType)
-
-