Details
-
Task
-
Status: Closed
-
Major
-
Resolution: Fixed
-
3.1M1
-
None
Description
Add annotations for lifecycle events:
@PrePersist, @PostPersist, etc. (all the standard ones, total of 8 annotations)
Each annotated method can process events for preset collection of entity classes and/or a set of unknown entity classes tagged with a custom annotation. In the later case a listener is cleanly decoupled from specific entities (this feature is mixin-inspired). E.g:
@Target(METHOD) @Retention(RUNTIME)
@PrePersist {
Class<? extends Persistent>[] entityTypes();
Class<? extends Annotation>[] entityAnnotations();
}
LifecycleCallbackRegistry API:
/**
- This form of listener registration is very simple and type-safe compared to other forms available in 3.0 LifecycleCallbackRegistry.
*/
public void addListener(Object annotatedListener);