Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 335709 - Invalid composite primary key validation error when redefining a simple primary key in a subclass
Summary: Invalid composite primary key validation error when redefining a simple prima...
Status: NEW
Alias: None
Product: Dali JPA Tools
Classification: WebTools
Component: JPA (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P2 normal (vote)
Target Milestone: Future   Edit
Assignee: Neil Hauge CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 338737 (view as bug list)
Depends on:
Blocks:
 
Reported: 2011-01-28 12:33 EST by Om Prakash CLA
Modified: 2014-02-06 14:21 EST (History)
4 users (show)

See Also:


Attachments
Its a Project Interchange file (45.24 KB, application/octet-stream)
2011-01-28 12:43 EST, Om Prakash CLA
no flags Details
Screenshot of error (42.16 KB, image/jpeg)
2011-01-28 12:46 EST, Om Prakash CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Om Prakash CLA 2011-01-28 12:33:38 EST
Build Identifier: Eclipse Platform  Version: 3.6.0.v20100602-9gF78GpqFt6trOGhL60z0oEx3fz-JKNwxPY Build id: I20100608-0911

After importing and building workspace its throwing errors in problems view i.e

Description	Resource	Path	Location	Type
An ancestor of this class has already defined the primary key. Primary key attributes may not be defined here.	Productresources.java	/OrderHandlingDBAccess/src/com/ibm/websphere/icp/telecom/reference/dynamicorderfulfillment	line 24	Validation Message
This class has a composite primary key.  It must use an ID class.	Productresources.java	/OrderHandlingDBAccess/src/com/ibm/websphere/icp/telecom/reference/dynamicorderfulfillment	line 22	Validation Message

Attaching the issue

Reproducible: Always

Steps to Reproduce:
1.Launch Eclipse
2.Import attached PI file( JPA-project-PI.zip )
3.Build the workspace and verify for any errors.
Comment 1 Om Prakash CLA 2011-01-28 12:43:07 EST
Created attachment 187857 [details]
Its a Project Interchange file

This issue was never there in earlier version i.e

Eclipse Platform

Version: 3.4.2.R342_v20090122-9I96EiWElHi8lheoJKJIvhM3JfVsYbRrgVIWL
Build id: M20091008-1320


But this issue popped up from version

Eclipse Platform

Version: 3.6.0.v20100602-9gF78GpqFt6trOGhL60z0oEx3fz-JKNwxPY
Build id: I20100608-0911

This is blocking our module to build.
Comment 2 Om Prakash CLA 2011-01-28 12:46:13 EST
Created attachment 187858 [details]
Screenshot of error
Comment 3 Neil Hauge CLA 2011-01-28 14:56:41 EST
Taking a look...may be related to bug 334134.
Comment 4 Neil Hauge CLA 2011-01-28 16:22:31 EST
So there are a couple of issues here.  The "ancestor" message is informing you that the key is being redefined in this class, which is not allowed in standard JPA as per the spec:

The primary key must be defined on the entity class that is the root of the entity hierarchy or on a mapped superclass that is a (direct or indirect) superclass of all entity classes in the entity hierarchy. The primary key must be defined exactly once in an entity hierarchy.

Various platforms may allow this configuration.  The platform extension in Dali allows adopters to customize this validation if it is different than what the spec allows.  For the "Generic" platform, this behavior is as designed.

The "composite primary key" message is being applied incorrectly in this case, as there aren't multiple, simple primary keys defined in this entity, but rather a redefined simple primary key.  This message would not appear once the patch for bug 334134 is applied, but that would only be coincidental as we will ignore this error until the PK redefined error is addressed.

I am curios as to why you are redefining the primary key in the Productresources entity.  Looking at the model this would appear to be unnecessary, and a bit confusing.  If this redefinition of the PK was removed, both of the reported errors would also be removed.

If you really needed to redefine the Id in this entity for some reason, the Dali JPA Platform extension that you are using "webSpherePlatform" would need to be updated to override the behavior of the validation logic contained in the Generic platform code. (This would require a separate bug against the WebSphere Tools) The Dali team would also need to address the bug in our composite primary key validation.

The last resort option is disabling the JPA Validator in the project properties.

Changing severity level of bug as there are several possible workarounds to allow for builds to continue.
Comment 5 Neil Hauge CLA 2011-02-02 14:41:00 EST
Any feedback?  Is there a request for this to be included in the Indigo maintenance line?
Comment 6 Neil Hauge CLA 2011-03-02 16:44:19 EST
(In reply to comment #5)
> Any feedback?  Is there a request for this to be included in the Indigo
> maintenance line?

This should have said the *Helios* maintenance stream.
Comment 7 Edwin Chan CLA 2011-03-02 16:55:38 EST
*** Bug 338737 has been marked as a duplicate of this bug. ***
Comment 8 Neil Hauge CLA 2011-07-01 16:23:57 EDT
Moving JPA specific bugs to new JPA component in bugzilla.
Comment 9 Neil Hauge CLA 2011-10-07 12:52:06 EDT
Targeting to Juno release.