| Summary: | [EclipseLink][Validation] No id class validation when id class defined on mapped superclass | ||||||||
|---|---|---|---|---|---|---|---|---|---|
| Product: | [WebTools] Dali JPA Tools | Reporter: | Nan Li <nan.n.li> | ||||||
| Component: | JPA | Assignee: | Nan Li <nan.n.li> | ||||||
| Status: | VERIFIED FIXED | QA Contact: | |||||||
| Severity: | normal | ||||||||
| Priority: | P3 | CC: | jolene.moffitt, neil.hauge, paul.fullbright | ||||||
| Version: | unspecified | ||||||||
| Target Milestone: | 3.4 M1 | ||||||||
| Hardware: | PC | ||||||||
| OS: | Windows 7 | ||||||||
| Whiteboard: | |||||||||
| Attachments: |
|
||||||||
|
Description
Nan Li
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.
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. Moving JPA specific bugs to new JPA component in bugzilla. Targeting to Juno release. Deferring this to 3.4 as it is somewhat risky to add new validation in this area for an RC. 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
Created attachment 234351 [details]
Proposed Patch
patch committed to the master Verified in build I-3.6.0-20130919105330 that mapped superclass has validation errors against the id class on EclipseLink platform. |