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
A base implementation of
EntityEntry.- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static enumRepresents a boolean flag stored within a number value, using one bit at a specified offset.protected static classAbstractEntityEntry.EnumState<E extends Enum<E>>Represents an enum value stored within a number value, using four bits starting at a specified offset. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected EntityKeyprotected final Objectprotected Object[]protected @Nullable ImmutableBitSetprotected EntityEntryExtraStateprotected final PersistenceContextprotected final EntityPersisterprotected final Objectprotected Object -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractEntityEntry(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
Modifier and TypeMethodDescriptionvoidaddExtraState(EntityEntryExtraState extraState) voidforceLocked(Object entity, Object nextVersion) protected booleanGets the current value of the given boolean flag.protected <E extends Enum<E>>
EGets the current value of the given enum property.Object[]Get theEntityKeyfor this entry.<T extends EntityEntryExtraState>
TgetExtraState(Class<T> extraStateType) final ObjectgetId()final Object[]getLoadedValue(String propertyName) @Nullable ImmutableBitSetHas a bit set for every attribute position that is potentially lazy.final EntityPersistergetRowId()final ObjectbooleanbooleanbooleanCan the entity be modified?booleanisNullifiable(boolean earlyInsert, SharedSessionContractImplementor session) booleanvoidoverwriteLoadedStateCollectionValue(String propertyName, PersistentCollection<?> collection) voidAfter actually deleting a row, record the fact that the instance no longer exists in the database.voidpostInsert(Object version) voidpostInsert(Object[] insertedState) After actually inserting a row, record the fact that the instance exists in 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) Returnstrueif the entity can possibly be dirty.voidCustom serialization routine used during serialization of aSession/PersistenceContextfor increased performance.protected voidsetCompressedValue(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.voidsetDeletedState(Object[] deletedState) voidsetLockMode(LockMode lockMode) voidsetMaybeLazySet(@Nullable ImmutableBitSet maybeLazySet) voidsetReadOnly(boolean readOnly, Object entity) voidtoString()
-
Field Details
-
id
-
loadedState
-
version
-
persister
-
cachedEntityKey
-
rowId
-
persistenceContext
-
maybeLazySet
-
next
-
-
Constructor Details
-
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 Details
-
getLockMode
- Specified by:
getLockModein interfaceEntityEntry
-
setLockMode
- Specified by:
setLockModein interfaceEntityEntry
-
getStatus
- Specified by:
getStatusin interfaceEntityEntry
-
setStatus
- Specified by:
setStatusin interfaceEntityEntry
-
getId
- Specified by:
getIdin interfaceEntityEntry
-
getLoadedState
- Specified by:
getLoadedStatein interfaceEntityEntry
-
getDeletedState
- Specified by:
getDeletedStatein interfaceEntityEntry
-
setDeletedState
- Specified by:
setDeletedStatein interfaceEntityEntry
-
isExistsInDatabase
public boolean isExistsInDatabase()- Specified by:
isExistsInDatabasein interfaceEntityEntry
-
getVersion
- Specified by:
getVersionin interfaceEntityEntry
-
postInsert
- Specified by:
postInsertin interfaceEntityEntry
-
getPersister
- Specified by:
getPersisterin interfaceEntityEntry
-
getEntityKey
Description copied from interface:EntityEntryGet theEntityKeyfor this entry.- Specified by:
getEntityKeyin interfaceEntityEntry- Returns:
- the
EntityKey
-
getEntityName
- Specified by:
getEntityNamein interfaceEntityEntry
-
isBeingReplicated
public boolean isBeingReplicated()- Specified by:
isBeingReplicatedin interfaceEntityEntry
-
getRowId
- Specified by:
getRowIdin interfaceEntityEntry
-
postUpdate
Description copied from interface:EntityEntryHandle 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:
postUpdatein 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:EntityEntryAfter actually deleting a row, record the fact that the instance no longer exists in the database.- Specified by:
postDeletein interfaceEntityEntry
-
postInsert
Description copied from interface:EntityEntryAfter actually inserting a row, record the fact that the instance exists in the database (needed for identity column key generation).- Specified by:
postInsertin interfaceEntityEntry
-
getLoadedValue
- Specified by:
getLoadedValuein interfaceEntityEntry
-
overwriteLoadedStateCollectionValue
public void overwriteLoadedStateCollectionValue(String propertyName, PersistentCollection<?> collection) - Specified by:
overwriteLoadedStateCollectionValuein interfaceEntityEntry
-
requiresDirtyCheck
Description copied from interface:EntityEntryReturnstrueif 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:
requiresDirtyCheckin interfaceEntityEntry- Parameters:
entity- The entity to test- Returns:
trueindicates that the entity could possibly be dirty and that the dirty-check should happen;falseindicates there is no way the entity can be dirty
-
isModifiableEntity
public boolean isModifiableEntity()Description copied from interface:EntityEntryCan 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:
isModifiableEntityin interfaceEntityEntry- Returns:
true, if the entity is modifiable;false, otherwise,
-
forceLocked
- Specified by:
forceLockedin interfaceEntityEntry
-
isReadOnly
public boolean isReadOnly()- Specified by:
isReadOnlyin interfaceEntityEntry
-
setReadOnly
- Specified by:
setReadOnlyin interfaceEntityEntry
-
getMaybeLazySet
Description copied from interface:EntityEntryHas 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:
getMaybeLazySetin interfaceEntityEntry
-
setMaybeLazySet
- Specified by:
setMaybeLazySetin interfaceEntityEntry
-
toString
- Specified by:
toStringin interfaceEntityEntry- Overrides:
toStringin classObject
-
serialize
Description copied from interface:EntityEntryCustom serialization routine used during serialization of aSession/PersistenceContextfor increased performance.- Specified by:
serializein interfaceEntityEntry- Parameters:
oos- The stream to which we should write the serial data.- Throws:
IOException- If a stream error occurs
-
addExtraState
- Specified by:
addExtraStatein interfaceEntityEntry
-
getExtraState
- Specified by:
getExtraStatein interfaceEntityEntry
-
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
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
Saves the value for the given boolean flag.- Parameters:
state- identifies the value to storevalue- the value to store
-
getCompressedValue
Gets the current value of the given boolean flag.- Parameters:
state- identifies the value to store- Returns:
- the current value of the specified flag
-