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

Bug 348316

Summary: [Validation] Error evaluating generic typed attribute type from subclass where generic is constrained
Product: [WebTools] Dali JPA Tools Reporter: elhanan Maayan <elh.mailgate>
Component: JPAAssignee: Paul Fullbright <paul.fullbright>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P2 CC: brian.vosburgh, karenfbutzke, neil.hauge, paul.fullbright
Version: unspecified   
Target Milestone: 3.3 M2   
Hardware: PC   
OS: Windows XP   
URL: https://bugs.eclipse.org/bugs/show_bug.cgi?id=258689
Whiteboard:
Attachments:
Description Flags
attached entities
none
test project
none
test project showing original Dali validation error none

Description elhanan Maayan CLA 2011-06-05 06:14:48 EDT
Resource: hr/src/com/pnx/hr/shared/model/JobHistory.java
Location: line 32

this problems shows on the enclosing classes even though it works in hibernate
Comment 1 elhanan Maayan CLA 2011-06-05 06:15:20 EDT
Created attachment 197350 [details]
attached entities
Comment 2 Paul Fullbright CLA 2011-06-06 16:29:42 EDT
It is difficult to determine the cause of the problem using the provided attachment.  There are too many dependencies missing.  I have tried to create a pared down project, but am not sure that the resultant code will still work in Hibernate.

Can you attach the simplest project that illustrates the problem without any external dependencies?
Comment 3 elhanan Maayan CLA 2011-06-07 01:34:39 EDT
actually i have additional info which may shed light on it, this happens if i define the id member  as a generic in AbstractPersistable class, onky extends it with EntityPersitable<Integer> instead of defining it directly in PersistableEntity
Comment 4 Paul Fullbright CLA 2011-06-14 16:08:53 EDT
Created attachment 197977 [details]
test project

Created usable project test case from previous attachment.
Comment 5 Paul Fullbright CLA 2011-06-14 17:14:59 EDT
The problem boils down to being able to resolve a type binding from within the scope of a subclass.

public class Foo<T> {

    public T bar;
}

public class SubFoo<Long> {}


When we analyze the type of bar, we currently look at the "erasure" of its type binding, which in this case will be Object.  And in this use case, it's not enough.  SubFoo imposes a stricter type binding on bar, and we must be able to resolve that type binding from within the context of SubFoo.

Our model definitely doesn't have the sophistication to handle this currently, and I doubt that it's something we can handle in a maintenance release.
Comment 6 Paul Fullbright CLA 2011-06-14 17:17:10 EDT
(the body of type SubFoo should actually read:

public class SubFoo extends Foo<Long> {}

)
Comment 7 elhanan Maayan CLA 2011-06-15 01:37:26 EDT
(In reply to comment #6)
> (the body of type SubFoo should actually read:
> 
> public class SubFoo extends Foo<Long> {}
> 
> )

the larger question is whether JPA specs support this kind of usage at all, or if they define it.

if they do not, then dali should provide an error stating so , 
if on other hand that behavior  is undefined, or is defined but dali is unable to support it, then it should provide a warning about it, at least untill it gets fixed or defined to prevent user from searching endlessly, as the original error doesn't give away much about it's true cause.
Comment 8 Neil Hauge CLA 2011-07-01 16:25:44 EDT
Moving JPA specific bugs to new JPA component in bugzilla.
Comment 9 Neil Hauge CLA 2011-10-07 12:51:56 EDT
Targeting to Juno release.
Comment 10 Neil Hauge CLA 2012-04-11 16:43:53 EDT
We should consider this for 3.2 M7.
Comment 11 Paul Fullbright CLA 2012-04-11 16:57:16 EDT
(In reply to comment #10)
> We should consider this for 3.2 M7.

I think we'll find the fix too large in scope at this point, but we can always spend time determining what the eventual fix will be.
Comment 12 Karen Butzke CLA 2012-04-30 16:44:29 EDT
Created attachment 214836 [details]
test project showing original Dali validation error

I've attached a pared down test project that shows the original error that the user reported. It seems to work fine in EclipseLink so I would assume it will work in Hibernate. The incorrect Dali validation error is: 'The type of the ID mapped by the relationship 'employee' does not agree with the primary key class of the target entity.' I was confused since this was originally listed in the subject line and is no longer.
Comment 13 Paul Fullbright CLA 2012-08-06 15:08:57 EDT
Committed new API for 3.3 M1 to address this issue.