• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Invocation order of Lifecycle Callback Methods

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
If a regular clown is funny, then a larger clown would be funnier. Math. Verified by this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic