public abstract class ImmutableEntityInterceptor
extends org.hibernate.EmptyInterceptor
NOTE: Subclasses MUST not make any changes to the persistent object because they get called last, if they make any changes other interceptors would never know about them.
Constructor and Description |
---|
ImmutableEntityInterceptor() |
Modifier and Type | Method and Description |
---|---|
void |
addMutablePropertiesForThread(String... properties)
This allows code that is attempting to save immutable entities to bypass standard validation by allowing
additional properties to be considered mutable for the duration of the thread.
|
protected String[] |
getMutablePropertyNames()
Subclasses can override this to return fields that are allowed to be edited, returning null
or an empty array implies the entity is immutable
|
protected abstract Class<?> |
getSupportedType()
Returns the class handled by the interceptor
|
protected boolean |
ignoreVoidedOrRetiredObjects()
Subclasses can override this to specify whether voided or retired items are mutable
|
boolean |
onFlushDirty(Object entity,
Serializable id,
Object[] currentState,
Object[] previousState,
String[] propertyNames,
org.hibernate.type.Type[] types) |
void |
removeMutablePropertiesForThread()
If any additional properties were added for a given thread by invoking
addMutablePropertiesForThread(java.lang.String...) ,
this removes them. |
afterTransactionBegin, afterTransactionCompletion, beforeTransactionCompletion, findDirty, getEntity, getEntityName, instantiate, isTransient, onCollectionRecreate, onCollectionRemove, onCollectionUpdate, onDelete, onLoad, onPrepareStatement, onSave, postFlush, preFlush
protected abstract Class<?> getSupportedType()
protected String[] getMutablePropertyNames()
protected boolean ignoreVoidedOrRetiredObjects()
public boolean onFlushDirty(Object entity, Serializable id, Object[] currentState, Object[] previousState, String[] propertyNames, org.hibernate.type.Type[] types)
onFlushDirty
in interface org.hibernate.Interceptor
onFlushDirty
in class org.hibernate.EmptyInterceptor
Should fail if an entity has a changed property
Should pass if an entity has changes for an allowed mutable property
Should pass if the edited object is voided or retired and ignore is set to true
Should fail if the edited object is voided or retired and ignore is set to false
public void addMutablePropertiesForThread(String... properties)
removeMutablePropertiesForThread()
is invoked when the operation is doneproperties
- any additional properties that one wishes to make mutable for a given threadpublic void removeMutablePropertiesForThread()
addMutablePropertiesForThread(java.lang.String...)
,
this removes them. NOTE, any usage of addMutablePropertiesForThread(java.lang.String...)
should typically be followed by
an invocation of this method in a finally blockCopyright © 2024 OpenMRS Inc.. All rights reserved.