Class CollectingAfterFlushEntityListener
java.lang.Object
ch.tocco.nice2.persist.core.api.util.CollectingAfterFlushEntityListener
- All Implemented Interfaces:
EntityFacadeListener
,CommitListener
,EventListener
- Direct Known Subclasses:
ClearAddressFieldsEntityListener
,DuplicateListener
,DuplicatesMergeListener
,DuplicatesSplitUpListener
,EntityHistoryFieldEntityListener
,EntityHistoryRelationEntityListener
,GenericResourcePublishEntityListener
public abstract class CollectingAfterFlushEntityListener
extends Object
implements EntityFacadeListener, CommitListener
An
EntityFacadeListener
that collects all events during a transaction.
The collected information is available from the CollectingAfterFlushEntityListener.EntityContext
when
onAfterFlush(Transaction)
is called.
onAfterFlush(Transaction)
is triggered by CommitListener.afterFlush(Transaction)
and must be implemented by subclasses and still runs inside the original transaction, but after the
INSERT, DELETE and UPDATE statements have been executed.
The priority()
must be carefully evaluated to make sure that other CollectingAfterFlushEntityListener
are not affected by this listener.
createEntityContext()
can be overridden to use a custom context if it is necessary to store additional
data that would be no longer available after the session is flushed.- See Also:
-
Nested Class Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
afterCommit
(Context context) Notifies about the point where the transaction has been fully committed.final boolean
Gets called after the changes of this transaction have been inserted into the database, but before the transaction is committed.final void
Notifies about the point where the transaction is about to be committed.final void
entityChanging
(EntityChangedEvent event) Fired when any changes are made to an entity.final void
entityCreating
(EntityFacadeEvent event) Fired when an entity is being created.final void
entityDeleting
(EntityFacadeEvent event) Fired when an entity is being deleted.final void
Fired when a relation of an entity has been changed.getEntityContext
(Context context) abstract boolean
protected void
protected void
protected void
protected void
abstract int
priority()
Defines execution order of allCollectingAfterFlushEntityListener
.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface ch.tocco.nice2.persist.core.api.entity.events.EntityFacadeListener
entityReceivedValues, handleSessionOnlyEntity
-
Constructor Details
-
CollectingAfterFlushEntityListener
public CollectingAfterFlushEntityListener()
-
-
Method Details
-
beforeCommit
Description copied from interface:CommitListener
Notifies about the point where the transaction is about to be committed.
This allows further modification of involved entities.
- Specified by:
beforeCommit
in interfaceCommitListener
- Parameters:
tx
- the transaction in question
-
afterFlush
Description copied from interface:CommitListener
Gets called after the changes of this transaction have been inserted into the database, but before the transaction is committed.- Specified by:
afterFlush
in interfaceCommitListener
- Returns:
- true if this method has modified the database
-
onAfterFlush
- Returns:
- true if this listeners has made any changes to the database
-
priority
public abstract int priority()Defines execution order of allCollectingAfterFlushEntityListener
. It is important to make sure that other listeners are not affected.- Specified by:
priority
in interfaceCommitListener
-
entityCreating
Description copied from interface:EntityFacadeListener
Fired when an entity is being created.- Specified by:
entityCreating
in interfaceEntityFacadeListener
- Parameters:
event
- The event object.
-
onEntityCreating
-
entityDeleting
Description copied from interface:EntityFacadeListener
Fired when an entity is being deleted.- Specified by:
entityDeleting
in interfaceEntityFacadeListener
- Parameters:
event
- The event Object
-
onEntityDeleting
-
entityChanging
Description copied from interface:EntityFacadeListener
Fired when any changes are made to an entity.- Specified by:
entityChanging
in interfaceEntityFacadeListener
- Parameters:
event
- The event object.
-
onEntityChanging
-
entityRelationChanging
Description copied from interface:EntityFacadeListener
Fired when a relation of an entity has been changed.- Specified by:
entityRelationChanging
in interfaceEntityFacadeListener
- Parameters:
event
- The event object.
-
onEntityRelationChanging
-
afterCommit
Description copied from interface:CommitListener
Notifies about the point where the transaction has been fully committed.
This allows post processing of the entities involved in the previous commit.
- Specified by:
afterCommit
in interfaceCommitListener
-
getEntityContext
-
createEntityContext
-