T
- the entity type@Indexed(value=EntityEventListener.class) public interface EntityEventListener<T> extends java.util.EventListener, io.micronaut.core.order.Ordered
Event listeners are able to listen for persistence events through the various method hooks provided.
The supports(RuntimePersistentEntity, Class)
method can be used to narrow applicable entities and
should be called by implementors prior to invoking one of the event methods.
Note that EntityEventListener
added by the user SHOULD NOT be annotated with Primary
.
Modifier and Type | Field and Description |
---|---|
static EntityEventListener<java.lang.Object> |
NOOP
A no-op event listener that does nothing.
|
Modifier and Type | Method and Description |
---|---|
default void |
postLoad(EntityEventContext<T> context)
A post-load hook.
|
default void |
postPersist(EntityEventContext<T> context)
A post-persist hook.
|
default void |
postRemove(EntityEventContext<T> context)
A post-remove hook.
|
default void |
postUpdate(EntityEventContext<T> context)
A post-update hook.
|
default boolean |
prePersist(EntityEventContext<T> context)
A pre-persist hook.
|
default boolean |
preQuery(QueryEventContext<T> context)
A pre-update hook.
|
default boolean |
preRemove(EntityEventContext<T> context)
A pre-remove hook.
|
default boolean |
preUpdate(EntityEventContext<T> context)
A pre-update hook.
|
default boolean |
supports(RuntimePersistentEntity<T> entity,
java.lang.Class<? extends java.lang.annotation.Annotation> eventType)
Allows including or excluding a listener for a specific entity.
|
static final EntityEventListener<java.lang.Object> NOOP
default boolean supports(RuntimePersistentEntity<T> entity, java.lang.Class<? extends java.lang.annotation.Annotation> eventType)
entity
- The entityeventType
- The event typedefault boolean prePersist(@NonNull EntityEventContext<T> context)
context
- The context objectdefault void postPersist(@NonNull EntityEventContext<T> context)
context
- The context objectdefault void postLoad(@NonNull EntityEventContext<T> context)
context
- The context objectdefault boolean preRemove(@NonNull EntityEventContext<T> context)
context
- The context objectdefault void postRemove(@NonNull EntityEventContext<T> context)
context
- The context objectdefault boolean preUpdate(@NonNull EntityEventContext<T> context)
context
- The context objectdefault boolean preQuery(@NonNull QueryEventContext<T> context)
context
- The context objectdefault void postUpdate(@NonNull EntityEventContext<T> context)
context
- The context object