Reputation: 170
Just curious.
Saw the rule from WebSphere: Duplicate life cycle callback methods If multiple callback methods are defined for an entity life cycle event, the ordering of the invocation of these methods is as follows: life cycle callback methods defined in the entity listeners: The life cycle callback methods that are defined on the entity listener classes for an entity class are invoked in the same order as the specification of the entity listener classes in the EntityListeners annotation or the XML descriptor. Listener super class: Callback methods defined in the super class of the entity listener are invoked before the children. Entity life cycle methods: WebSphere® eXtreme Scale does not support entity inheritance, so the entity life cycle methods can only be defined in the entity class.
But it only mentioned the scenario multiple callbacks are from different listeners.
What if one callback (say @PostLoad) was defined in the entity class, but another (also @PostLoad) from the listener?
Which callback method would be invoked first? Is the sequence specified or provider-dependent?
Thanks a lot!
Upvotes: 0
Views: 649
Reputation: 42114
Method in listener is called first, then callback method in entity is called. To be more specific, order is:
Call order is specified in detail (and with clarifying examples) in JPA 2.0 specification, 3.5 Entity Listeners and Callback Methods.
Upvotes: 2