Forums Register Login

Invocation order of Lifecycle Callback Methods

+Pie Number of slices to send: Send
Below is an example from MZ notes showing the order of invocation of entity lifecycle callback methods.
Can somebody please explain why the method "postPersistAnimal" is invoked last instead of first. I thought it would be called
first since class Pet extends Animal.

thanks



CASE 1: If a @PostPersist event occurs on an instance of Cat, the following methods are called
in order:
1 postPersistPetListenerMethod
2 postPersistCatListenerMethod
3 postPersistCatListener2Method
4 postPersistAnimal
+Pie Number of slices to send: Send
Because there are two types of ordering for interceptors, first there is the declaration:
1. Default interceptors(those declared in the orm.xml)
2. Class interceptors
3. Method interceptors

Per declaration type the order is:
1. Super class
2. Own class

Hope this helps
This tiny ad is guaranteed to be gluten free.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1166 times.
Similar Threads
a strange question about polymorphism
What's the point in casting a superclass to subclass?
Entity callback doubt
Many @PostConstruct methods?
Override Entity Callback Method
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 10:36:58.