aspose file tools*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Invocation order of Lifecycle Callback Methods Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Invocation order of Lifecycle Callback Methods" Watch "Invocation order of Lifecycle Callback Methods" New topic

Invocation order of Lifecycle Callback Methods

Moses Marfo

Joined: May 24, 2009
Posts: 27
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.


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
Roland Benedek

Joined: Jun 06, 2008
Posts: 6
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
I agree. Here's the link:
subject: Invocation order of Lifecycle Callback Methods
Similar Threads
What's the point in casting a superclass to subclass?
Override Entity Callback Method
a strange question about polymorphism
Entity callback doubt
Many @PostConstruct methods?