Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 334134

Summary: Invalid validation error about entity deriving from mapped superclass with composite key
Product: [WebTools] Dali JPA Tools Reporter: Leonard Theivendra <theivend>
Component: GeneralAssignee: Neil Hauge <neil.hauge>
Status: RESOLVED FIXED QA Contact:
Severity: major    
Priority: P2 CC: david_williams, kaloyan, neil.hauge
Version: unspecifiedFlags: david_williams: pmc_approved+
neil.hauge: pmc_approved? (raghunathan.srinivasan)
neil.hauge: pmc_approved? (naci.dai)
neil.hauge: pmc_approved? (deboer)
neil.hauge: pmc_approved? (neil.hauge)
kaloyan: pmc_approved+
neil.hauge: review+
Target Milestone: 2.3.3   
Hardware: PC   
OS: Windows XP   
Whiteboard: PMC_approved
Attachments:
Description Flags
mapped super class
none
entity class
none
composite key class
none
Patch none

Description Leonard Theivendra CLA 2011-01-12 11:57:43 EST
Build Identifier: Dali 2.3 / WTP 3.2

For a entity extending from a mapped superclass with an idclass composite key, the JPA validator emits this error message:
Description	Resource	Path	Location	Type
This class has a composite primary key.  It must use an ID class.	CodeXX.java	/JPA1/src/adtek/test	line 8	Validation Message

The error message occurs for JPA 1.0 and 2.0, and doesn't occur in Dali 2.0.x. Not sure if this is a bug in the Dali 2.3 validator or if it is new validation that wasn't there in Dali 2.0

Reproducible: Always

Steps to Reproduce:
1. Create a JPA 1.0 or 2.0 project
2. Copy the attached .java classes into the source folder (mapped super class, entity class, composite key class)
Comment 1 Leonard Theivendra CLA 2011-01-12 11:58:56 EST
Created attachment 186650 [details]
mapped super class
Comment 2 Leonard Theivendra CLA 2011-01-12 11:59:19 EST
Created attachment 186651 [details]
entity class
Comment 3 Leonard Theivendra CLA 2011-01-12 11:59:35 EST
Created attachment 186652 [details]
composite key class
Comment 4 Neil Hauge CLA 2011-01-13 10:42:55 EST
This does appear to be an invalid error message.  Will fix for next service release.
Comment 5 Neil Hauge CLA 2011-01-27 00:51:09 EST
Created attachment 187710 [details]
Patch

This patch will short circuit the offending validation for the Generic case where this is an issue.  Other validation will apply in the cases where validation is needed.
Comment 6 Neil Hauge CLA 2011-01-31 18:03:28 EST
* Explain why you believe this is a stop-ship defect. Or, if it is a "hotbug"
(requested by an adopter) please document it as such. 

This is a fix for an invalid error message, and is an adopter issue.  Very high priority.

* Is there a work-around? If so, why do you believe the work-around is
insufficient? 

No real workaround without turning off all JPA validation.

* How has the fix been tested? Is there a test case attached to the bugzilla
record? Has a JUnit Test been added?

JUnit tests have been run.  Manual tests have been run.

* Give a brief technical overview. Who has reviewed this fix?

The validation will now short-circuit if any part of the primary key is defined in a superclass.  Some minor refactoring was required to ensure that the fix was applied in all of the proper places (both Entity and MappedSuperclass).  Paul has reviewed the fix.  

* What is the risk associated with this fix? 

Medium risk, but worth it for high severity issue.  Manual and automated tests have been run to ensure that there are no regressions in common usage.
Comment 7 Neil Hauge CLA 2011-02-01 18:13:43 EST
Patch committed to 2.3.x maintenance.  Fix also applied to Head.