Session
are dirty, meaning modified. Dirty entities will be UPDATEed in the database.
In some circumstances, the process of determining whether an entity is dirty can carry a significant overhead, since, by default, Hibernate must check each of the entity's attribute values one by one. Sometimes, an application already has knowledge of an entity's dirtiness and making use of that information would save some work. This contract allows the application to take over the task of determining if an entity is dirty.
org.hibernate.cfg.AvailableSettings#CUSTOM_ENTITY_DIRTINESS_STRATEGY , org.hibernate.cfg.Configuration#setCustomEntityDirtinessStrategy(CustomEntityDirtinessStrategy) , org.hibernate.boot.SessionFactoryBuilder#applyCustomEntityDirtinessStrategy(CustomEntityDirtinessStrategy)
| Modifier and Type | Class and Description |
|---|---|
| public static interface | CustomEntityDirtinessStrategy.AttributeChecker
Responsible for identifying when attributes are dirty. |
| public static interface | CustomEntityDirtinessStrategy.AttributeInformation
Provides |
| public static interface | CustomEntityDirtinessStrategy.DirtyCheckContext
A callback to drive dirty checking. |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | Returns: true indicates the dirty check can be done; false indicates it cannot.The entity to be checked entity, EntityPersister The persister corresponding to the given entity persister, Session The session from which this check originates. session)Is this strategy capable of telling whether the given entity is dirty? |
| public void | findDirty(Object
The entity being checked entity, EntityPersister The persister corresponding to the given entity persister, Session The session from which this call originates. session, CustomEntityDirtinessStrategy.The callback context dirtyCheckContextCallback used to hook into Hibernate algorithm for determination of which attributes have changed. |
| public boolean | Returns: true indicates the entity is dirty; false indicates the entity is not dirty.The entity to check. entity, EntityPersister The persister corresponding to the given entity persister, Session The session from which this check originates. session)The callback used by Hibernate to determine if the given entity is dirty. |
| public void | resetDirty(Object
The entity to reset entity, EntityPersister The persister corresponding to the given entity persister, Session The session from which this call originates. session)Callback used by Hibernate to signal that the entity dirty flag should be cleared. |
| canDirtyCheck | back to summary |
|---|---|
| public boolean canDirtyCheck(Object entity, EntityPersister persister, Session session) Is this strategy capable of telling whether the given entity is dirty? A return of
| |
| findDirty | back to summary |
|---|---|
| public void findDirty(Object entity, EntityPersister persister, Session session, CustomEntityDirtinessStrategy. Callback used to hook into Hibernate algorithm for determination of which attributes have changed. Applications
wanting to hook in to this would call back into the given
| |
| isDirty | back to summary |
|---|---|
| public boolean isDirty(Object entity, EntityPersister persister, Session session) The callback used by Hibernate to determine if the given entity is dirty. Only called if the previous
| |
| resetDirty | back to summary |
|---|---|
| public void resetDirty(Object entity, EntityPersister persister, Session session) Callback used by Hibernate to signal that the entity dirty flag should be cleared. Generally this happens after previous dirty changes were written to the database.
| |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | Returns: true indicates the attribute value has changed; false indicates it has not.Information about the attribute which is useful to help determine if it is
dirty. attributeInformationDo the attribute dirty check. |
| isDirty | back to summary |
|---|---|
| public boolean isDirty(CustomEntityDirtinessStrategy. Do the attribute dirty check.
| |
AttributeChecker with meta information about the attributes being checked.
| Modifier and Type | Method and Description |
|---|---|
| public int | Returns: The attribute index.Many of Hibernate internals use arrays to define information about attributes. |
| public EntityPersister | Returns: The entity persister.Get a reference to the persister for the entity containing this attribute. |
| public Object | |
| public Object | |
| public String | |
| public Type |
| getAttributeIndex | back to summary |
|---|---|
| public int getAttributeIndex() Many of Hibernate internals use arrays to define information about attributes. This value provides this index into those arrays for this particular attribute. It can be useful if needing to leverage those Hibernate internals.
| |
| getContainingPersister | back to summary |
|---|---|
| public EntityPersister getContainingPersister() Get a reference to the persister for the entity containing this attribute.
| |
| getCurrentValue | back to summary |
|---|---|
| public Object getCurrentValue() Get the current value of this attribute.
| |
| getLoadedValue | back to summary |
|---|---|
| public Object getLoadedValue() Get the loaded value of this attribute. NOTE : A call to this method may require hitting the database in cases where the loaded state is not known. In those cases the db hit is incurred only once per entity, not for each attribute.
| |
| getName | back to summary |
|---|---|
| public String getName() Get the name of this attribute.
| |
| getType | back to summary |
|---|---|
| public Type getType() Get the mapping type of this attribute.
| |
CustomEntityDirtinessStrategy#findDirty method
so that it can call back in to it if it wants to handle dirty checking rather than using Hibernate's default
checking.
| Modifier and Type | Method and Description |
|---|---|
| public void | doDirtyChecking(CustomEntityDirtinessStrategy.
The delegate usable by the context for determining which attributes are dirty. attributeCheckerThe callback to indicate that dirty checking (the dirty attribute determination phase) should be handled
by the calling |
| doDirtyChecking | back to summary |
|---|---|
| public void doDirtyChecking(CustomEntityDirtinessStrategy. The callback to indicate that dirty checking (the dirty attribute determination phase) should be handled
by the calling
| |