Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 348316 - [Validation] Error evaluating generic typed attribute type from subclass where generic is constrained
Summary: [Validation] Error evaluating generic typed attribute type from subclass wher...
Status: RESOLVED FIXED
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: 3.3 M2   Edit
Assignee: Paul Fullbright CLA
QA Contact:
URL: https://bugs.eclipse.org/bugs/show_bu...
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-06-05 06:14 EDT by elhanan Maayan CLA
Modified: 2012-08-20 11:42 EDT (History)
4 users (show)

See Also:


Attachments
attached entities (15.37 KB, application/octet-stream)
2011-06-05 06:15 EDT, elhanan Maayan CLA
no flags Details
test project (7.53 KB, application/x-zip-compressed)
2011-06-14 16:08 EDT, Paul Fullbright CLA
no flags Details
test project showing original Dali validation error (9.45 KB, application/octet-stream)
2012-04-30 16:44 EDT, Karen Butzke CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
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.