Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 348361 - Event definitions (pre-persist, pre-update ..) are ignored when defined in <mapped-superclass>
Summary: Event definitions (pre-persist, pre-update ..) are ignored when defined in <m...
Status: RESOLVED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P3 major (vote)
Target Milestone: ---   Edit
Assignee: Nobody - feel free to take it CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-06-06 04:27 EDT by CorForLive CLA
Modified: 2022-06-09 10:19 EDT (History)
2 users (show)

See Also:


Attachments
Proposed changes (5.40 KB, patch)
2011-06-09 14:33 EDT, Guy Pelletier CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description CorForLive CLA 2011-06-06 04:27:10 EDT
Build Identifier: 

Situation:
- The whole domain model is defined in the orm.xml file. All entities are simple POJOs (no jpa annotations are used at all). 
- All entities extend a base entity declared in the orm.xml using <mapped-superclass ..> 

Problem:
Adding event declarations (pre-persist, pre-update ..) into orm.xml to the mapped-superclass does not bring any effect. These declarations seem to be ignored. Example:

public abstract class BaseEntity {

  private Timestamp insertTimestamp;
  private Timestamp lastUpdateTimestamp;

  public void onPersist() {
    ...   
  }

  public void onUpdate() {
    ...
  }
}

<mapped-superclass class="com.my.model.BaseEntity">
   <pre-persist method-name="onPersist"/>
   <pre-update method-name="onUpdate"/>
   <post-load method-name="postLoad"/>
</mapped-superclass> 

Replacing the xml definitions with annotations (@PreUpdate, @PrePersist, ..) directly in the BaseEntity class solves the problem. Also moving the xml declarations from the superclass to the subclass solved the problem.

It look like the bug while the parsing/mapping the <mapped-superclass> XML declaration. Event declarations seem to be ignored / don't work. The annotation-based equivalent seems to work correctly.

I'm using EclipseLink 2.2.0 with H2 in the SE environment developing under MacOs+IntelliJ

Reproducible: Always

Steps to Reproduce:
1. Create an entity class and declare as entity using orm.xml
2. Create a superclass for the created entity class and declare in orm.xml using <mapped-superclass>
3. Add <pre-persist> and/or <pre-update> to the superclass in the orm.xml
4. Persist and/or update the entity and check wether the events method in the base class are being called.
Comment 1 Guy Pelletier CLA 2011-06-09 14:33:21 EDT
Created attachment 197719 [details]
Proposed changes
Comment 2 Guy Pelletier CLA 2011-06-09 14:57:32 EDT
Changes submitted.

Verified by: Tom Ware

Tests: Modified existing test (testCreateBeerConsumer) from EntityMappingsInheritedJUnitTestCase.
Comment 3 Eclipse Webmaster CLA 2022-06-09 10:19:07 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink