Package org.hibernate.engine.internal
Class AbstractEntityEntry
- java.lang.Object
-
- org.hibernate.engine.internal.AbstractEntityEntry
-
- All Implemented Interfaces:
Serializable
,EntityEntry
- Direct Known Subclasses:
ImmutableEntityEntry
,MutableEntityEntry
public abstract class AbstractEntityEntry extends Object implements Serializable, EntityEntry
A base implementation ofEntityEntry
.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
AbstractEntityEntry.BooleanState
Represents a boolean flag stored within a number value, using one bit at a specified offset.protected static class
AbstractEntityEntry.EnumState<E extends Enum<E>>
Represents an enum value stored within a number value, using four bits starting at a specified offset.
-
Field Summary
Fields Modifier and Type Field Description protected EntityKey
cachedEntityKey
protected Object
id
protected Object[]
loadedState
protected @Nullable ImmutableBitSet
maybeLazySet
protected EntityEntryExtraState
next
protected PersistenceContext
persistenceContext
protected EntityPersister
persister
protected Object
rowId
protected Object
version
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractEntityEntry(SessionFactoryImplementor factory, String entityName, Object id, Status status, Status previousStatus, Object[] loadedState, Object[] deletedState, Object version, LockMode lockMode, boolean existsInDatabase, boolean isBeingReplicated, PersistenceContext persistenceContext)
This for is used during custom deserialization handlingAbstractEntityEntry(Status status, Object[] loadedState, Object rowId, Object id, Object version, LockMode lockMode, boolean existsInDatabase, EntityPersister persister, boolean disableVersionIncrement, PersistenceContext persistenceContext)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addExtraState(EntityEntryExtraState extraState)
void
forceLocked(Object entity, Object nextVersion)
protected boolean
getCompressedValue(AbstractEntityEntry.BooleanState state)
Gets the current value of the given boolean flag.protected <E extends Enum<E>>
EgetCompressedValue(AbstractEntityEntry.EnumState<E> state)
Gets the current value of the given enum property.Object[]
getDeletedState()
EntityKey
getEntityKey()
Get theEntityKey
for this entry.String
getEntityName()
<T extends EntityEntryExtraState>
TgetExtraState(Class<T> extraStateType)
Object
getId()
Object[]
getLoadedState()
Object
getLoadedValue(String propertyName)
LockMode
getLockMode()
@Nullable ImmutableBitSet
getMaybeLazySet()
Has a bit set for every attribute position that is potentially lazy.PersistenceContext
getPersistenceContext()
EntityPersister
getPersister()
Object
getRowId()
Status
getStatus()
Object
getVersion()
boolean
isBeingReplicated()
boolean
isExistsInDatabase()
boolean
isModifiableEntity()
Can the entity be modified?boolean
isNullifiable(boolean earlyInsert, SharedSessionContractImplementor session)
boolean
isReadOnly()
void
overwriteLoadedStateCollectionValue(String propertyName, PersistentCollection<?> collection)
void
postDelete()
After actually deleting a row, record the fact that the instance no longer exists in the database.void
postInsert(Object version)
void
postInsert(Object[] insertedState)
After actually inserting a row, record the fact that the instance exists in the database (needed for identity column key generation).void
postUpdate(Object entity, Object[] updatedState, Object nextVersion)
Handle updating the internal state of the entry after actually performing the database update.boolean
requiresDirtyCheck(Object entity)
Returnstrue
if the entity can possibly be dirty.void
serialize(ObjectOutputStream oos)
Custom serialization routine used during serialization of aSession
/PersistenceContext
for increased performance.protected void
setCompressedValue(AbstractEntityEntry.BooleanState state, boolean value)
Saves the value for the given boolean flag.protected <E extends Enum<E>>
voidsetCompressedValue(AbstractEntityEntry.EnumState<E> state, E value)
Saves the value for the given enum property.void
setDeletedState(Object[] deletedState)
void
setLockMode(LockMode lockMode)
void
setMaybeLazySet(@Nullable ImmutableBitSet maybeLazySet)
void
setReadOnly(boolean readOnly, Object entity)
void
setStatus(Status status)
String
toString()
-
-
-
Field Detail
-
id
protected final Object id
-
loadedState
protected Object[] loadedState
-
version
protected Object version
-
persister
protected final EntityPersister persister
-
cachedEntityKey
protected transient EntityKey cachedEntityKey
-
rowId
protected final transient Object rowId
-
persistenceContext
protected final transient PersistenceContext persistenceContext
-
maybeLazySet
protected transient @Nullable ImmutableBitSet maybeLazySet
-
next
protected EntityEntryExtraState next
-
-
Constructor Detail
-
AbstractEntityEntry
public AbstractEntityEntry(Status status, Object[] loadedState, Object rowId, Object id, Object version, LockMode lockMode, boolean existsInDatabase, EntityPersister persister, boolean disableVersionIncrement, PersistenceContext persistenceContext)
-
AbstractEntityEntry
protected AbstractEntityEntry(SessionFactoryImplementor factory, String entityName, Object id, Status status, Status previousStatus, Object[] loadedState, Object[] deletedState, Object version, LockMode lockMode, boolean existsInDatabase, boolean isBeingReplicated, PersistenceContext persistenceContext)
This for is used during custom deserialization handling
-
-
Method Detail
-
getLockMode
public LockMode getLockMode()
- Specified by:
getLockMode
in interfaceEntityEntry
-
setLockMode
public void setLockMode(LockMode lockMode)
- Specified by:
setLockMode
in interfaceEntityEntry
-
getStatus
public Status getStatus()
- Specified by:
getStatus
in interfaceEntityEntry
-
setStatus
public void setStatus(Status status)
- Specified by:
setStatus
in interfaceEntityEntry
-
getId
public final Object getId()
- Specified by:
getId
in interfaceEntityEntry
-
getLoadedState
public final Object[] getLoadedState()
- Specified by:
getLoadedState
in interfaceEntityEntry
-
getDeletedState
public Object[] getDeletedState()
- Specified by:
getDeletedState
in interfaceEntityEntry
-
setDeletedState
public void setDeletedState(Object[] deletedState)
- Specified by:
setDeletedState
in interfaceEntityEntry
-
isExistsInDatabase
public boolean isExistsInDatabase()
- Specified by:
isExistsInDatabase
in interfaceEntityEntry
-
getVersion
public final Object getVersion()
- Specified by:
getVersion
in interfaceEntityEntry
-
postInsert
public void postInsert(Object version)
- Specified by:
postInsert
in interfaceEntityEntry
-
getPersister
public final EntityPersister getPersister()
- Specified by:
getPersister
in interfaceEntityEntry
-
getEntityKey
public EntityKey getEntityKey()
Description copied from interface:EntityEntry
Get theEntityKey
for this entry.- Specified by:
getEntityKey
in interfaceEntityEntry
- Returns:
- the
EntityKey
-
getEntityName
public String getEntityName()
- Specified by:
getEntityName
in interfaceEntityEntry
-
isBeingReplicated
public boolean isBeingReplicated()
- Specified by:
isBeingReplicated
in interfaceEntityEntry
-
getRowId
public Object getRowId()
- Specified by:
getRowId
in interfaceEntityEntry
-
postUpdate
public void postUpdate(Object entity, Object[] updatedState, Object nextVersion)
Description copied from interface:EntityEntry
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.- Specified by:
postUpdate
in interfaceEntityEntry
- Parameters:
entity
- The entity instanceupdatedState
- The state calculated after the update (becomes the newloaded state
.nextVersion
- The new version.
-
postDelete
public void postDelete()
Description copied from interface:EntityEntry
After actually deleting a row, record the fact that the instance no longer exists in the database.- Specified by:
postDelete
in interfaceEntityEntry
-
postInsert
public void postInsert(Object[] insertedState)
Description copied from interface:EntityEntry
After actually inserting a row, record the fact that the instance exists in the database (needed for identity column key generation).- Specified by:
postInsert
in interfaceEntityEntry
-
isNullifiable
public boolean isNullifiable(boolean earlyInsert, SharedSessionContractImplementor session)
- Specified by:
isNullifiable
in interfaceEntityEntry
-
getLoadedValue
public Object getLoadedValue(String propertyName)
- Specified by:
getLoadedValue
in interfaceEntityEntry
-
overwriteLoadedStateCollectionValue
public void overwriteLoadedStateCollectionValue(String propertyName, PersistentCollection<?> collection)
- Specified by:
overwriteLoadedStateCollectionValue
in interfaceEntityEntry
-
requiresDirtyCheck
public boolean requiresDirtyCheck(Object entity)
Description copied from interface:EntityEntry
Returnstrue
if the entity can possibly be dirty. This can only be the case if it is in a modifiable state (not read-only nor deleted) and it either has mutable properties or field-interception is not telling us that it is dirty.- Specified by:
requiresDirtyCheck
in interfaceEntityEntry
- Parameters:
entity
- The entity to test- Returns:
true
indicates that the entity could possibly be dirty and that the dirty-check should happen;false
indicates there is no way the entity can be dirty
-
isModifiableEntity
public boolean isModifiableEntity()
Description copied from interface:EntityEntry
Can the entity be modified?The entity is modifiable if all the following are true:
- the entity class is mutable,
- the entity is not read-only, and
- if the current status is
Status.DELETED
, then the entity was not read-only when it was deleted.
- Specified by:
isModifiableEntity
in interfaceEntityEntry
- Returns:
true
, if the entity is modifiable;false
, otherwise,
-
forceLocked
public void forceLocked(Object entity, Object nextVersion)
- Specified by:
forceLocked
in interfaceEntityEntry
-
isReadOnly
public boolean isReadOnly()
- Specified by:
isReadOnly
in interfaceEntityEntry
-
setReadOnly
public void setReadOnly(boolean readOnly, Object entity)
- Specified by:
setReadOnly
in interfaceEntityEntry
-
getMaybeLazySet
public @Nullable ImmutableBitSet getMaybeLazySet()
Description copied from interface:EntityEntry
Has a bit set for every attribute position that is potentially lazy. Whennull
, no knowledge is available and every attribute must be assumed potentially lazy.- Specified by:
getMaybeLazySet
in interfaceEntityEntry
-
setMaybeLazySet
public void setMaybeLazySet(@Nullable ImmutableBitSet maybeLazySet)
- Specified by:
setMaybeLazySet
in interfaceEntityEntry
-
toString
public String toString()
- Specified by:
toString
in interfaceEntityEntry
- Overrides:
toString
in classObject
-
serialize
public void serialize(ObjectOutputStream oos) throws IOException
Description copied from interface:EntityEntry
Custom serialization routine used during serialization of aSession
/PersistenceContext
for increased performance.- Specified by:
serialize
in interfaceEntityEntry
- Parameters:
oos
- The stream to which we should write the serial data.- Throws:
IOException
- If a stream error occurs
-
addExtraState
public void addExtraState(EntityEntryExtraState extraState)
- Specified by:
addExtraState
in interfaceEntityEntry
-
getExtraState
public <T extends EntityEntryExtraState> T getExtraState(Class<T> extraStateType)
- Specified by:
getExtraState
in interfaceEntityEntry
-
getPersistenceContext
public PersistenceContext getPersistenceContext()
-
setCompressedValue
protected <E extends Enum<E>> void setCompressedValue(AbstractEntityEntry.EnumState<E> state, E value)
Saves the value for the given enum property.- Parameters:
state
- identifies the value to storevalue
- the value to store; The caller must make sure that it matches the given identifier
-
getCompressedValue
protected <E extends Enum<E>> E getCompressedValue(AbstractEntityEntry.EnumState<E> state)
Gets the current value of the given enum property.- Parameters:
state
- identifies the value to store- Returns:
- the current value of the specified property
-
setCompressedValue
protected void setCompressedValue(AbstractEntityEntry.BooleanState state, boolean value)
Saves the value for the given boolean flag.- Parameters:
state
- identifies the value to storevalue
- the value to store
-
getCompressedValue
protected boolean getCompressedValue(AbstractEntityEntry.BooleanState state)
Gets the current value of the given boolean flag.- Parameters:
state
- identifies the value to store- Returns:
- the current value of the specified flag
-
-