Class EmptyInterceptor

java.lang.Object
org.hibernate.internal.EmptyInterceptor
All Implemented Interfaces:
Serializable, Interceptor

public final class EmptyInterceptor extends Object implements Interceptor, Serializable
An interceptor that does nothing. This is an internal class and should not be used as a base to implement a custom Interceptor; it is similar to the public, deprecated EmptyInterceptor but overrides the default methods for sake of efficiency: this wasn't possible on the original deprecated copy as that wouldn't have been backwards compatible. For this reason this copy is internal. Implementors of Interceptor don't need a base class anymore since we now have default implementations of the contract defined in the interface.
See Also:
  • Field Details

  • Method Details

    • onLoad

      public boolean onLoad(Object entity, Object id, Object[] state, String[] propertyNames, Type[] types)
      Description copied from interface: Interceptor
      Called just before an object is initialized. The interceptor may change the state, which will be propagated to the persistent object. Note that when this method is called, entity will be an empty uninitialized instance of the class.
      Specified by:
      onLoad in interface Interceptor
      Parameters:
      entity - The entity instance being loaded
      id - The identifier value being loaded
      state - The entity state (which will be pushed into the entity instance)
      propertyNames - The names of the entity properties, corresponding to the state.
      types - The types of the entity properties, corresponding to the state.
      Returns:
      true if the user modified the state in any way.
    • onFlushDirty

      public boolean onFlushDirty(Object entity, Object id, Object[] currentState, Object[] previousState, String[] propertyNames, Type[] types)
      Description copied from interface: Interceptor
      Called when an object is detected to be dirty, during a flush. The interceptor may modify the detected currentState, which will be propagated to both the database and the persistent object. Note that not all flushes end in actual synchronization with the database, in which case the new currentState will be propagated to the object, but not necessarily (immediately) to the database. It is strongly recommended that the interceptor not modify the previousState.
      Specified by:
      onFlushDirty in interface Interceptor
      Parameters:
      entity - The entity instance detected as being dirty and being flushed
      id - The identifier of the entity
      currentState - The entity's current state
      previousState - The entity's previous (load time) state.
      propertyNames - The names of the entity properties
      types - The types of the entity properties
      Returns:
      true if the user modified the currentState in any way.
      See Also:
    • onSave

      public boolean onSave(Object entity, Object id, Object[] state, String[] propertyNames, Type[] types)
      Description copied from interface: Interceptor
      Called before an object is made persistent by a stateful session.

      The interceptor may modify the state, which will be used for the SQL INSERT and propagated to the persistent object.

      Specified by:
      onSave in interface Interceptor
      Parameters:
      entity - The entity instance whose state is being inserted
      id - The identifier of the entity
      state - The state of the entity which will be inserted
      propertyNames - The names of the entity properties.
      types - The types of the entity properties
      Returns:
      true if the user modified the state in any way.
      See Also:
    • onDelete

      public void onDelete(Object entity, Object id, Object[] state, String[] propertyNames, Type[] types)
      Description copied from interface: Interceptor
      Called before an object is removed by a stateful session.

      It is not recommended that the interceptor modify the state.

      Specified by:
      onDelete in interface Interceptor
      Parameters:
      entity - The entity instance being deleted
      id - The identifier of the entity
      state - The state of the entity
      propertyNames - The names of the entity properties.
      types - The types of the entity properties
      See Also:
    • findDirty

      public int[] findDirty(Object entity, Object id, Object[] currentState, Object[] previousState, String[] propertyNames, Type[] types)
      Description copied from interface: Interceptor
      Called from flush(). The return value determines whether the entity is updated
      • an array of property indices - the entity is dirty
      • an empty array - the entity is not dirty
      • null - use Hibernate's default dirty-checking algorithm
      Specified by:
      findDirty in interface Interceptor
      Parameters:
      entity - The entity for which to find dirty properties.
      id - The identifier of the entity
      currentState - The current entity state as taken from the entity instance
      previousState - The state of the entity when it was last synchronized (generally when it was loaded)
      propertyNames - The names of the entity properties.
      types - The types of the entity properties
      Returns:
      array of dirty property indices or null to indicate Hibernate should perform default behaviour
    • getEntity

      public Object getEntity(String entityName, Object id)
      Description copied from interface: Interceptor
      Get a fully loaded entity instance that is cached externally.
      Specified by:
      getEntity in interface Interceptor
      Parameters:
      entityName - the name of the entity
      id - the instance identifier
      Returns:
      a fully initialized entity