Hitachi

uCosminexus Application Server Compatibility Guide


9.15.3 Order of invoking the callback methods

If multiple callback methods are defined for an entity, the invocation order follows the below rules:

  1. The default listeners are invoked in the order defined in the O/R mapping file.

    Unless @ExcludeDefaultListeners or the <exclude-default-listeners> tag of the O/R mapping file is explicitly specified, the default listeners are applied to all the entities in the persistence unit.

  2. The callback methods are invoked in the order specified in @EntityListeners.

    Note that if you use the O/R mapping file, you can execute the following operations:

    • Specifying the order of invoking the callback methods for the entities.

    • Overriding the order specified in the annotations.

  3. The callback method specified in the entity (or mapped superclass) is invoked.

Organization of this subsection

(1) Invocation order in the inheritance hierarchy

If the entity listener is defined multiple times in the inheritance hierarchy of the entity class and mapped superclass, the invocation order is as follows:

  1. The default callback listener, if present, is invoked first.

  2. The callback methods of the entity listener class are invoked sequentially from the listener specified in the superclass. At this time, if items such as @EntityListener are specified, that order is followed.

  3. After the callback methods of all the entity listeners are invoked, the callback methods defined in the entity (or mapped superclass) are invoked sequentially from the listener specified in the superclass.

If the callback method is overridden in the subclass, the overridden method is not invoked. If the overridden callback method specifies different lifecycle events or if the overridden callback method is not a lifecycle callback method, the overridden method is invoked. Also, the callback method settings of the method are overridden.

(2) Excluding the callback methods