Top Description Inners Fields Constructors Methods
org.hibernate.engine.internal

public abstract Class AbstractEntityEntry

extends Object
implements Serializable, EntityEntry
Class Inheritance
All Implemented Interfaces
org.hibernate.engine.spi.EntityEntry, java.io.Serializable
Known Direct Subclasses
org.hibernate.engine.internal.ImmutableEntityEntry, org.hibernate.engine.internal.MutableEntityEntry
Imports
java.io.IOException, .ObjectOutputStream, .Serializable, org.hibernate.AssertionFailure, .CustomEntityDirtinessStrategy, .EntityMode, .HibernateException, .LockMode, .Session, org.hibernate.bytecode.enhance.spi.interceptor.EnhancementAsProxyLazinessInterceptor, org.hibernate.collection.spi.PersistentCollection, org.hibernate.engine.spi.CachedNaturalIdValueSource, .EntityEntry, .EntityEntryExtraState, .EntityKey, .Managed, .PersistenceContext, .PersistentAttributeInterceptable, .PersistentAttributeInterceptor, .SelfDirtinessTracker, .SessionFactoryImplementor, .SharedSessionContractImplementor, .Status, org.hibernate.persister.entity.EntityPersister, .UniqueKeyLoadable, org.hibernate.pretty.MessageHelper, org.hibernate.proxy.HibernateProxy

A base implementation of EntityEntry
Authors
Gavin King, Emmanuel Bernard, Gunnar Morling, Sanne Grinovero

Nested and Inner Type Summary

Modifier and TypeClass and Description
protected static enum
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

Modifier and TypeField and Description
protected transient EntityKey
private transient int
compressedState

Holds several boolean and enum typed attributes in a very compact manner.

private static final Object[]
protected final Serializable
protected Object[]
protected EntityEntryExtraState
protected final transient PersistenceContext
protected final EntityPersister
protected final transient Object
protected Object

Constructor Summary

AccessConstructor and Description
public
AbstractEntityEntry(final Status status, final Object[] loadedState, final Object rowId, final Serializable id, final Object version, final LockMode lockMode, final boolean existsInDatabase, final EntityPersister persister, final EntityMode entityMode, final String tenantId, final boolean disableVersionIncrement, final PersistenceContext persistenceContext)

Deprecated the tenantId and entityMode parameters where removed: this constructor accepts but ignores them. Use the other constructor!
public
AbstractEntityEntry(final Status status, final Object[] loadedState, final Object rowId, final Serializable id, final Object version, final LockMode lockMode, final boolean existsInDatabase, final EntityPersister persister, final boolean disableVersionIncrement, final PersistenceContext persistenceContext)

protected
AbstractEntityEntry(final SessionFactoryImplementor factory, final String entityName, final Serializable id, final Status status, final Status previousStatus, final Object[] loadedState, final Object[] deletedState, final Object version, final LockMode lockMode, final boolean existsInDatabase, final boolean isBeingReplicated, final PersistenceContext persistenceContext)

Deprecated as a consequence of SessionFactoryImplementor being deprecated.
This for is used during custom deserialization handling

Method Summary

Modifier and TypeMethod and Description
public void
private static void
public void
protected <E extends Enum<E>> E

Returns:

the current value of the specified property
getCompressedValue
(AbstractEntityEntry.EnumState<E>
identifies the value to store
state
)

Gets the current value of the given enum property.

protected boolean

Returns:

the current value of the specified flag
getCompressedValue
(AbstractEntityEntry.BooleanState
identifies the value to store
state
)

Gets the current value of the given boolean flag.

public Object[]
public EntityKey
getEntityKey()

Implements org.hibernate.engine.spi.EntityEntry.getEntityKey.

Get the EntityKey based on this EntityEntry.
public String
public <T extends EntityEntryExtraState> T
public Serializable
public Object[]
public Object
public LockMode
public PersistenceContext
public EntityPersister
private Status
public Object
public Status
public Object
public boolean
public boolean
public boolean
public boolean
public boolean
private boolean
public void
public void
postDelete()

Implements org.hibernate.engine.spi.EntityEntry.postDelete.

After actually deleting a row, record the fact that the instance no longer exists in the database
public void
postInsert(Object[] insertedState)

Implements org.hibernate.engine.spi.EntityEntry.postInsert.

After actually inserting a row, record the fact that the instance exists on the database (needed for identity-column key generation)
public void
postUpdate(Object
The entity instance
entity
,
Object[]
The state calculated after the update (becomes the new loaded state.
updatedState
,
Object
The new version.
nextVersion
)

Implements org.hibernate.engine.spi.EntityEntry.postUpdate.

Handle updating the internal state of the entry after actually performing the database update.
public boolean
requiresDirtyCheck(Object
The entity to test
entity
)

Implements org.hibernate.engine.spi.EntityEntry.requiresDirtyCheck.

Not sure this is the best method name, but the general idea here is to return true if the entity can possibly be dirty.
public void
serialize(ObjectOutputStream
The stream to which we should write the serial data.
oos
)

Implements org.hibernate.engine.spi.EntityEntry.serialize.

Custom serialization routine used during serialization of a Session/PersistenceContext for increased performance.
protected <E extends Enum<E>> void
setCompressedValue(AbstractEntityEntry.EnumState<E>
identifies the value to store
state
,
E
the value to store; The caller must make sure that it matches the given identifier
value
)

Saves the value for the given enum property.

protected void
setCompressedValue(AbstractEntityEntry.BooleanState
identifies the value to store
state
,
boolean
the value to store
value
)

Saves the value for the given boolean flag.

public void
public void
public void
public void
public String
toString()

Overrides java.lang.Object.toString.

Implements org.hibernate.engine.spi.EntityEntry.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

cachedEntityKeyback to summary
protected transient EntityKey cachedEntityKey
compressedStateback to summary
private transient int compressedState

Holds several boolean and enum typed attributes in a very compact manner. Enum values are stored in 4 bits (where 0 represents null, and each enum value is represented by its ordinal value + 1), thus allowing for up to 15 values per enum. Boolean values are stored in one bit.

The value is structured as follows:

1 - Lock mode
2 - Status
3 - Previous Status
4 - existsInDatabase
5 - isBeingReplicated
6 - loadedWithLazyPropertiesUnfetched; NOTE: this is not updated when properties are fetched lazily!

0000 0000 | 0000 0000 | 0654 3333 | 2222 1111
Use setCompressedValue(org.hibernate.engine.internal.AbstractEntityEntry.EnumState, Enum), getCompressedValue(org.hibernate.engine.internal.AbstractEntityEntry.EnumState) etc to access the enums and booleans stored in this value.

Representing enum values by their ordinal value is acceptable for our case as this value itself is never serialized or deserialized and thus is not affected should ordinal values change.

DEFAULT_DELETED_STATEback to summary
private static final Object[] DEFAULT_DELETED_STATE
idback to summary
protected final Serializable id
loadedStateback to summary
protected Object[] loadedState
nextback to summary
protected EntityEntryExtraState next
persistenceContextback to summary
protected final transient PersistenceContext persistenceContext
persisterback to summary
protected final EntityPersister persister
rowIdback to summary
protected final transient Object rowId
versionback to summary
protected Object version

Constructor Detail

AbstractEntityEntryback to summary
public AbstractEntityEntry(final Status status, final Object[] loadedState, final Object rowId, final Serializable id, final Object version, final LockMode lockMode, final boolean existsInDatabase, final EntityPersister persister, final EntityMode entityMode, final String tenantId, final boolean disableVersionIncrement, final PersistenceContext persistenceContext)

Deprecated

the tenantId and entityMode parameters where removed: this constructor accepts but ignores them. Use the other constructor!

Annotations
@Deprecated
AbstractEntityEntryback to summary
public AbstractEntityEntry(final Status status, final Object[] loadedState, final Object rowId, final Serializable id, final Object version, final LockMode lockMode, final boolean existsInDatabase, final EntityPersister persister, final boolean disableVersionIncrement, final PersistenceContext persistenceContext)
AbstractEntityEntryback to summary
protected AbstractEntityEntry(final SessionFactoryImplementor factory, final String entityName, final Serializable id, final Status status, final Status previousStatus, final Object[] loadedState, final Object[] deletedState, final Object version, final LockMode lockMode, final boolean existsInDatabase, final boolean isBeingReplicated, final PersistenceContext persistenceContext)

Deprecated

as a consequence of SessionFactoryImplementor being deprecated. See corresponding docs for further information.

This for is used during custom deserialization handling

Annotations
@SuppressWarnings:JavaDoc

Method Detail

addExtraStateback to summary
public void addExtraState(EntityEntryExtraState extraState)

Implements org.hibernate.engine.spi.EntityEntry.addExtraState.

Annotations
@Override
clearDirtyAttributesback to summary
private static void clearDirtyAttributes(final SelfDirtinessTracker entity)
forceLockedback to summary
public void forceLocked(Object entity, Object nextVersion)

Implements org.hibernate.engine.spi.EntityEntry.forceLocked.

Annotations
@Override
getCompressedValueback to summary
protected <E extends Enum<E>> E getCompressedValue(AbstractEntityEntry.EnumState<E> state)

Gets the current value of the given enum property.

Parameters
state:AbstractEntityEntry.EnumState<E>

identifies the value to store

Returns:E

the current value of the specified property

getCompressedValueback to summary
protected boolean getCompressedValue(AbstractEntityEntry.BooleanState state)

Gets the current value of the given boolean flag.

Parameters
state:AbstractEntityEntry.BooleanState

identifies the value to store

Returns:boolean

the current value of the specified flag

getDeletedStateback to summary
public Object[] getDeletedState()

Implements org.hibernate.engine.spi.EntityEntry.getDeletedState.

Annotations
@Override
getEntityKeyback to summary
public EntityKey getEntityKey()

Implements org.hibernate.engine.spi.EntityEntry.getEntityKey.

Doc from org.hibernate.engine.spi.EntityEntry.getEntityKey.

Get the EntityKey based on this EntityEntry.

Returns:EntityKey

the EntityKey

Annotations
@Override
getEntityNameback to summary
public String getEntityName()

Implements org.hibernate.engine.spi.EntityEntry.getEntityName.

Annotations
@Override
getExtraStateback to summary
public <T extends EntityEntryExtraState> T getExtraState(Class<T> extraStateType)

Implements org.hibernate.engine.spi.EntityEntry.getExtraState.

Annotations
@Override
getIdback to summary
public Serializable getId()

Implements org.hibernate.engine.spi.EntityEntry.getId.

Annotations
@Override
getLoadedStateback to summary
public Object[] getLoadedState()

Implements org.hibernate.engine.spi.EntityEntry.getLoadedState.

Annotations
@Override
getLoadedValueback to summary
public Object getLoadedValue(String propertyName)

Implements org.hibernate.engine.spi.EntityEntry.getLoadedValue.

Annotations
@Override
getLockModeback to summary
public LockMode getLockMode()

Implements org.hibernate.engine.spi.EntityEntry.getLockMode.

Annotations
@Override
getPersistenceContextback to summary
public PersistenceContext getPersistenceContext()
getPersisterback to summary
public EntityPersister getPersister()

Implements org.hibernate.engine.spi.EntityEntry.getPersister.

Annotations
@Override
getPreviousStatusback to summary
private Status getPreviousStatus()
getRowIdback to summary
public Object getRowId()

Implements org.hibernate.engine.spi.EntityEntry.getRowId.

Annotations
@Override
getStatusback to summary
public Status getStatus()

Implements org.hibernate.engine.spi.EntityEntry.getStatus.

Annotations
@Override
getVersionback to summary
public Object getVersion()

Implements org.hibernate.engine.spi.EntityEntry.getVersion.

Annotations
@Override
isBeingReplicatedback to summary
public boolean isBeingReplicated()

Implements org.hibernate.engine.spi.EntityEntry.isBeingReplicated.

Annotations
@Override
isExistsInDatabaseback to summary
public boolean isExistsInDatabase()

Implements org.hibernate.engine.spi.EntityEntry.isExistsInDatabase.

Annotations
@Override
isModifiableEntityback to summary
public boolean isModifiableEntity()

Implements org.hibernate.engine.spi.EntityEntry.isModifiableEntity.

Doc from org.hibernate.engine.spi.EntityEntry.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:boolean

true, if the entity is modifiable; false, otherwise,

Annotations
@Override
isNullifiableback to summary
public boolean isNullifiable(boolean earlyInsert, SharedSessionContractImplementor session)

Implements org.hibernate.engine.spi.EntityEntry.isNullifiable.

Annotations
@Override
isReadOnlyback to summary
public boolean isReadOnly()

Implements org.hibernate.engine.spi.EntityEntry.isReadOnly.

Annotations
@Override
isUnequivocallyNonDirtyback to summary
private boolean isUnequivocallyNonDirty(Object entity)
Annotations
@SuppressWarnings:SimplifiableIfStatement
overwriteLoadedStateCollectionValueback to summary
public void overwriteLoadedStateCollectionValue(String propertyName, PersistentCollection collection)

Implements org.hibernate.engine.spi.EntityEntry.overwriteLoadedStateCollectionValue.

Annotations
@Override
postDeleteback to summary
public void postDelete()

Implements org.hibernate.engine.spi.EntityEntry.postDelete.

Doc from org.hibernate.engine.spi.EntityEntry.postDelete.

After actually deleting a row, record the fact that the instance no longer exists in the database

Annotations
@Override
postInsertback to summary
public void postInsert(Object[] insertedState)

Implements org.hibernate.engine.spi.EntityEntry.postInsert.

Doc from org.hibernate.engine.spi.EntityEntry.postInsert.

After actually inserting a row, record the fact that the instance exists on the database (needed for identity-column key generation)

Annotations
@Override
postUpdateback to summary
public void postUpdate(Object entity, Object[] updatedState, Object nextVersion)

Implements org.hibernate.engine.spi.EntityEntry.postUpdate.

Doc from org.hibernate.engine.spi.EntityEntry.postUpdate.

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:Object

The entity instance

updatedState:Object[]

The state calculated after the update (becomes the new loaded state.

nextVersion:Object

The new version.

Annotations
@Override
requiresDirtyCheckback to summary
public boolean requiresDirtyCheck(Object entity)

Implements org.hibernate.engine.spi.EntityEntry.requiresDirtyCheck.

Doc from org.hibernate.engine.spi.EntityEntry.requiresDirtyCheck.

Not sure this is the best method name, but the general idea here is to return true 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:Object

The entity to test

Returns:boolean

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

Annotations
@Override
serializeback to summary
public void serialize(ObjectOutputStream oos) throws IOException

Implements org.hibernate.engine.spi.EntityEntry.serialize.

Doc from org.hibernate.engine.spi.EntityEntry.serialize.

Custom serialization routine used during serialization of a Session/PersistenceContext for increased performance.

Parameters
oos:ObjectOutputStream

The stream to which we should write the serial data.

Annotations
@Override
Exceptions
IOException:
If a stream error occurs
setCompressedValueback to summary
protected <E extends Enum<E>> void setCompressedValue(AbstractEntityEntry.EnumState<E> state, E value)

Saves the value for the given enum property.

Parameters
state:AbstractEntityEntry.EnumState<E>

identifies the value to store

value:E

the value to store; The caller must make sure that it matches the given identifier

setCompressedValueback to summary
protected void setCompressedValue(AbstractEntityEntry.BooleanState state, boolean value)

Saves the value for the given boolean flag.

Parameters
state:AbstractEntityEntry.BooleanState

identifies the value to store

value:boolean

the value to store

setDeletedStateback to summary
public void setDeletedState(Object[] deletedState)

Implements org.hibernate.engine.spi.EntityEntry.setDeletedState.

Annotations
@Override
setLockModeback to summary
public void setLockMode(LockMode lockMode)

Implements org.hibernate.engine.spi.EntityEntry.setLockMode.

Annotations
@Override
setReadOnlyback to summary
public void setReadOnly(boolean readOnly, Object entity)

Implements org.hibernate.engine.spi.EntityEntry.setReadOnly.

Annotations
@Override
setStatusback to summary
public void setStatus(Status status)

Implements org.hibernate.engine.spi.EntityEntry.setStatus.

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Implements org.hibernate.engine.spi.EntityEntry.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override
org.hibernate.engine.internal back to summary

protected final Enum AbstractEntityEntry.BooleanState

extends Enum<AbstractEntityEntry.BooleanState>
Class Inheritance

Represents a boolean flag stored within a number value, using one bit at a specified offset.
Author
Gunnar Morling

Field Summary

Modifier and TypeField and Description
public static final AbstractEntityEntry.BooleanState
public static final AbstractEntityEntry.BooleanState
private final int
private final int
private final int

Constructor Summary

AccessConstructor and Description
private
BooleanState(int offset)

Method Summary

Modifier and TypeMethod and Description
private int
getMask()

Returns the bit mask for reading this flag from the number value storing it.

private int
getOffset()

Returns the offset within the number value at which this boolean flag is stored.

private int
getUnsetMask()

Returns the bit mask for resetting this flag from the number value storing it.

private int
getValue(boolean value)

public static AbstractEntityEntry.BooleanState
public static AbstractEntityEntry.BooleanState[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

EXISTS_IN_DATABASEback to summary
public static final AbstractEntityEntry.BooleanState EXISTS_IN_DATABASE
IS_BEING_REPLICATEDback to summary
public static final AbstractEntityEntry.BooleanState IS_BEING_REPLICATED
maskback to summary
private final int mask
offsetback to summary
private final int offset
unsetMaskback to summary
private final int unsetMask

Constructor Detail

BooleanStateback to summary
private BooleanState(int offset)

Method Detail

getMaskback to summary
private int getMask()

Returns the bit mask for reading this flag from the number value storing it.

getOffsetback to summary
private int getOffset()

Returns the offset within the number value at which this boolean flag is stored.

getUnsetMaskback to summary
private int getUnsetMask()

Returns the bit mask for resetting this flag from the number value storing it.

getValueback to summary
private int getValue(boolean value)
valueOfback to summary
public static AbstractEntityEntry.BooleanState valueOf(String name)
valuesback to summary
public static AbstractEntityEntry.BooleanState[] values()
org.hibernate.engine.internal back to summary

protected Class AbstractEntityEntry.EnumState<E extends java.lang.Enum<E>>

extends Object
Class Inheritance

Represents an enum value stored within a number value, using four bits starting at a specified offset.
Author
Gunnar Morling

Field Summary

Modifier and TypeField and Description
protected final E[]
protected static final AbstractEntityEntry.EnumState<LockMode>
protected final int
protected final int
protected static final AbstractEntityEntry.EnumState<Status>
protected static final AbstractEntityEntry.EnumState<Status>
protected final int

Constructor Summary

AccessConstructor and Description
private
EnumState(int offset, Class<E> enumType)

Method Summary

Modifier and TypeMethod and Description
private E[]
getEnumConstants()

Returns the constants of the represented enum which is cached for performance reasons.

private int
getMask()

Returns the bit mask for reading this enum value from the number value storing it.

private int
getOffset()

Returns the offset within the number value at which this enum value is stored.

private int
getUnsetMask()

Returns the bit mask for resetting this enum value from the number value storing it.

private int
getValue(E value)

Returns the numeric value to be stored for the given enum value.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

enumConstantsback to summary
protected final E[] enumConstants
LOCK_MODEback to summary
protected static final AbstractEntityEntry.EnumState<LockMode> LOCK_MODE
maskback to summary
protected final int mask
offsetback to summary
protected final int offset
PREVIOUS_STATUSback to summary
protected static final AbstractEntityEntry.EnumState<Status> PREVIOUS_STATUS
STATUSback to summary
protected static final AbstractEntityEntry.EnumState<Status> STATUS
unsetMaskback to summary
protected final int unsetMask

Constructor Detail

EnumStateback to summary
private EnumState(int offset, Class<E> enumType)

Method Detail

getEnumConstantsback to summary
private E[] getEnumConstants()

Returns the constants of the represented enum which is cached for performance reasons.

getMaskback to summary
private int getMask()

Returns the bit mask for reading this enum value from the number value storing it.

getOffsetback to summary
private int getOffset()

Returns the offset within the number value at which this enum value is stored.

getUnsetMaskback to summary
private int getUnsetMask()

Returns the bit mask for resetting this enum value from the number value storing it.

getValueback to summary
private int getValue(E value)

Returns the numeric value to be stored for the given enum value.