Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 347842 - [EclipseLink][Validation] No id class validation when id class defined on mapped superclass
Summary: [EclipseLink][Validation] No id class validation when id class defined on map...
Status: VERIFIED FIXED
Alias: None
Product: Dali JPA Tools
Classification: WebTools
Component: JPA (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: 3.4 M1   Edit
Assignee: Nan Li CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-05-31 14:15 EDT by Nan Li CLA
Modified: 2013-09-25 12:24 EDT (History)
3 users (show)

See Also:


Attachments
Proposed Patch (9.39 KB, patch)
2013-08-12 09:28 EDT, Nan Li CLA
no flags Details | Diff
Proposed Patch (11.31 KB, patch)
2013-08-13 09:38 EDT, Nan Li CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Nan Li CLA 2011-05-31 14:15:48 EDT
Build Identifier: I20110525-0800

Mapped superclass has no validation against id class on EclipseLink platform.

Reproducible: Always
Comment 1 Nan Li CLA 2011-05-31 17:32:26 EDT
One use case could be

public class EmpId {
	private int id1;
	private int id2;
}

@MappedSuperclass
@IdClass(EmpId.class)
public abstract class CompanyEmployee {
	@Id private String id1;
}

@Entity
public class PartTimeEmployee extends CompanyEmployee {
	@Id private int id;
}

There should be at least a couple of validation errors against PartTimeEmployee entity: 

1) Attribute id1 in the mapped superclass does not have the correct type
2) There is no primary key attribute to match the ID class attribute id2

The rest of the id class validation available when defining id class on an entity should also apply when defining id class on a mapped superclass.
Comment 2 Nan Li CLA 2011-05-31 17:45:21 EDT
To clarify, mapped superclass should not have validation against id class, extending entities should. Currently, if defining an id class on an entity itself, validation works; however, no validation if defining an id class on a mapped superclass.
Comment 3 Neil Hauge CLA 2011-07-01 16:25:44 EDT
Moving JPA specific bugs to new JPA component in bugzilla.
Comment 4 Neil Hauge CLA 2011-10-07 12:51:55 EDT
Targeting to Juno release.
Comment 5 Neil Hauge CLA 2013-05-07 12:09:39 EDT
Deferring this to 3.4 as it is somewhat risky to add new validation in this area for an RC.
Comment 6 Nan Li CLA 2013-08-12 09:28:56 EDT
Created attachment 234309 [details]
Proposed Patch

This is how the validation works after the changes:

- If an entity defines an ID class itself, validate against this ID class and validation text ranges goes to the ID class defined on the entity
- If a mapped superclass defines an ID class, validate against this ID class and validation text range goes to the root entity, which has pros and cons:
pro: in EclipseLink, it's only the root entity where the id class matters so it makes sense validating id class against the root entity.
con: if the primary keys are defined on multiple mapped superclasses, it would be hard for user to find the primary key that has issue.

The patch was created based on the following commit:

f7567be fix intermittent NPE in ItemTreeStateProviderManager when adding or
renaming a project Brian Vosburgh
Comment 7 Nan Li CLA 2013-08-13 09:38:24 EDT
Created attachment 234351 [details]
Proposed Patch
Comment 8 Nan Li CLA 2013-08-13 12:08:47 EDT
patch committed to the master
Comment 9 Jolene Moffitt CLA 2013-09-25 12:24:32 EDT
Verified in build I-3.6.0-20130919105330 that mapped superclass has validation errors against the id class on EclipseLink platform.