Class CustomFlushEntityEventListener
java.lang.Object
org.hibernate.event.internal.DefaultFlushEntityEventListener
ch.tocco.nice2.persist.core.impl.hibernate.listener.CustomFlushEntityEventListener
- All Implemented Interfaces:
Serializable
,org.hibernate.event.spi.FlushEntityEventListener
,org.hibernate.jpa.event.spi.CallbackRegistryConsumer
public class CustomFlushEntityEventListener
extends org.hibernate.event.internal.DefaultFlushEntityEventListener
This is a workaround for firing after commit events (
EntityListener
) when only the collection
of an entity has changed.
Hibernate does not fire a EventType.POST_COMMIT_UPDATE
event when only the (non-owning side)
of a relation is changed (because no change is required for this entity on the database for this table).
In this listener we check if this is the case and fire the event manually through the AfterCommitListener
.- See Also:
-
Constructor Summary
ConstructorDescriptionCustomFlushEntityEventListener
(AfterCommitListener afterCommitListener, PropertyAccessorService propertyAccessorService) -
Method Summary
Modifier and TypeMethodDescriptionvoid
onFlushEntity
(org.hibernate.event.spi.FlushEntityEvent event) Methods inherited from class org.hibernate.event.internal.DefaultFlushEntityEventListener
checkId, dirtyCheck, handleInterception, injectCallbackRegistry, invokeInterceptor, isUpdateNecessary
-
Constructor Details
-
CustomFlushEntityEventListener
public CustomFlushEntityEventListener(AfterCommitListener afterCommitListener, PropertyAccessorService propertyAccessorService)
-
-
Method Details
-
onFlushEntity
public void onFlushEntity(org.hibernate.event.spi.FlushEntityEvent event) throws org.hibernate.HibernateException - Specified by:
onFlushEntity
in interfaceorg.hibernate.event.spi.FlushEntityEventListener
- Overrides:
onFlushEntity
in classorg.hibernate.event.internal.DefaultFlushEntityEventListener
- Throws:
org.hibernate.HibernateException
-