Package org.hibernate.engine.spi
Interface EntityEntry
-
public interface EntityEntry
We 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 void
addExtraState(EntityEntryExtraState extraState)
void
forceLocked(java.lang.Object entity, java.lang.Object nextVersion)
java.lang.Object[]
getDeletedState()
EntityKey
getEntityKey()
Get the EntityKey based on this EntityEntry.java.lang.String
getEntityName()
<T extends EntityEntryExtraState>
TgetExtraState(java.lang.Class<T> extraStateType)
java.io.Serializable
getId()
java.lang.Object[]
getLoadedState()
java.lang.Object
getLoadedValue(java.lang.String propertyName)
LockMode
getLockMode()
EntityPersister
getPersister()
java.lang.Object
getRowId()
Status
getStatus()
java.lang.Object
getVersion()
boolean
isBeingReplicated()
boolean
isExistsInDatabase()
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 deletedboolean
isNullifiable(boolean earlyInsert, SharedSessionContractImplementor session)
boolean
isReadOnly()
void
overwriteLoadedStateCollectionValue(java.lang.String propertyName, PersistentCollection collection)
void
postDelete()
After actually deleting a row, record the fact that the instance no longer exists in the databasevoid
postInsert(java.lang.Object[] insertedState)
After actually inserting a row, record the fact that the instance exists on the database (needed for identity-column key generation)void
postUpdate(java.lang.Object entity, java.lang.Object[] updatedState, java.lang.Object nextVersion)
Handle updating the internal state of the entry after actually performing the database update.boolean
requiresDirtyCheck(java.lang.Object entity)
Not sure this is the best method name, but the general idea here is to returntrue
if the entity can possibly be dirty.void
serialize(java.io.ObjectOutputStream oos)
Custom serialization routine used during serialization of a Session/PersistenceContext for increased performance.void
setDeletedState(java.lang.Object[] deletedState)
void
setLockMode(LockMode lockMode)
void
setReadOnly(boolean readOnly, java.lang.Object entity)
void
setStatus(Status status)
java.lang.String
toString()
-
-
-
Method Detail
-
getLockMode
LockMode getLockMode()
-
setLockMode
void setLockMode(LockMode lockMode)
-
getStatus
Status getStatus()
-
setStatus
void setStatus(Status status)
-
getId
java.io.Serializable getId()
-
getLoadedState
java.lang.Object[] getLoadedState()
-
getLoadedValue
java.lang.Object getLoadedValue(java.lang.String propertyName)
-
overwriteLoadedStateCollectionValue
void overwriteLoadedStateCollectionValue(java.lang.String propertyName, PersistentCollection collection)
-
getDeletedState
java.lang.Object[] getDeletedState()
-
setDeletedState
void setDeletedState(java.lang.Object[] deletedState)
-
isExistsInDatabase
boolean isExistsInDatabase()
-
getVersion
java.lang.Object getVersion()
-
getPersister
EntityPersister getPersister()
-
getEntityKey
EntityKey getEntityKey()
Get the EntityKey based on this EntityEntry.- Returns:
- the EntityKey
- Throws:
java.lang.IllegalStateException
- if getId() is null
-
getEntityName
java.lang.String getEntityName()
-
isBeingReplicated
boolean isBeingReplicated()
-
getRowId
java.lang.Object getRowId()
-
postUpdate
void postUpdate(java.lang.Object entity, java.lang.Object[] updatedState, java.lang.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(java.lang.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(java.lang.Object entity)
Not sure this is the best method name, but the general idea here is to returntrue
if 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:
true
indicates that the entity could possibly be dirty and that dirty check should happen;false
indicates 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,
-
forceLocked
void forceLocked(java.lang.Object entity, java.lang.Object nextVersion)
-
isReadOnly
boolean isReadOnly()
-
setReadOnly
void setReadOnly(boolean readOnly, java.lang.Object entity)
-
toString
java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
serialize
void serialize(java.io.ObjectOutputStream oos) throws java.io.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:
java.io.IOException
- If a stream error occurs
-
addExtraState
void addExtraState(EntityEntryExtraState extraState)
-
getExtraState
<T extends EntityEntryExtraState> T getExtraState(java.lang.Class<T> extraStateType)
-
-