Community
Participate
Working Groups
Build Identifier: 20110615-0604 Let B be an entity class, which inherits from a @MappedSuperclass A. A defines a numeric version column called "version" and annotated with @Version. B uses an @AttributeOverride annotation for overriding the column name of the version attribute. For this case, the JPA validation reports the following error on class B: Attribute override "version" cannot be resolved to an attribute on the mapped superclass "A" However, no validation error should be produced here. This scenario used to be validated successfully in Eclipse versions prior to 3.7. Reproducible: Always Steps to Reproduce: 1. Create a JPA project, so that JPA validation can be used. 2. Create two entities implementing this scenario (see attached files). 3. Run validation.
Created attachment 202491 [details] Demo code for mapped superclass A
Created attachment 202492 [details] Demo code for entity B
Thanks for reporting this one Martin! In Eclipse 3.7 Dali attempted to enhance our existing validation support with a number of new errors. In this case it appears we have taken the spec too literally when it says "The AttributeOverride annotation is used to override the mapping of a Basic (whether explicit or default) property or field or Id property or field." in section 11.1.4. For the 3.0.1 release we should open up attribute overrides to allow version mappings. For a future release we probably need to add another validation for overriding a mapping that is not a correct type (Basic, Id, or Version). It is confusing to have the error that the attribute override cannot be resolved, when the attribute does exist.
As a workaround until 3.0.1 is released you can turn off this particular validation. In the workspace preferences under JavaPersistence->JPA->Errors/Warnings find 'Attribute override name cannot be resolved to an attribute', it's the 2nd error under Database->Attribute/association overrides. Set this to 'Ignore'.
Created attachment 202623 [details] proposed patch against 3.0 maintenance This patch simply change java and orm version attribute mapping to be 'overridable attribute mappings'. It also updates the appropriate tests.
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 regression, and is very high priority given that it is an invalid error message. Is there a work-around? If so, why do you believe the work-around is insufficient? There is a workaround (see comment 4) but it removes this broad error message which may cause false validation results for other attribute override situations where there should be an error. How has the fix been tested? Is there a test case attached to the bugzilla record? Has a JUnit Test been added? Karen has tested the patch, units tests have been run and updated as necessary. Give a brief technical overview. Who has reviewed this fix? See comment 5. I have reviewed the fix. What is the risk associated with this fix? Risk is low. Fix is small and well understood.
Patch looks good - thanks
a "normal" level of severity? But, does look important to fix. Tip for future: its easier to review if patch the "main" code is separate from the test code. At first I was thinking "what a huge change" ... but at least some is for test code only. Guess there's pros and cons both ways. Looks pretty boiler plate, so I think it safe.
committed this patch to maintenance and head
Verified in Build M-3.3.1-20110915193224 Verified the validation error does not exist when you create a JPA project with the attached two entities. See the link to view test steps for verification. http://wiki.eclipse.org/Dali_3.0.1