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

Bug 354623

Summary: incorrect JPA Problem: In attribute 'employee', the "maps ID" value 'employee' does not refer to an attribute that is used as an ID for this entity
Product: [WebTools] Dali JPA Tools Reporter: elhanan Maayan <elh.mailgate>
Component: JPAAssignee: Neil Hauge <neil.hauge>
Status: RESOLVED INVALID QA Contact:
Severity: normal    
Priority: P3 CC: neil.hauge
Version: unspecified   
Target Milestone: 3.0.1   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Attachments:
Description Flags
entire project none

Description elhanan Maayan CLA 2011-08-12 09:59:45 EDT
Resource: hr/src/com/hr/model/impl/JobHistory.java
Location: line 28
this happens even thought hibernate works with it, the id is there, it's just in super class
Comment 1 elhanan Maayan CLA 2011-08-12 10:02:46 EDT
Created attachment 201399 [details]
entire project
Comment 2 elhanan Maayan CLA 2011-08-12 10:03:13 EDT
Comment on attachment 201399 [details]
entire project

i've excluded the jars becouse of the size
Comment 3 Neil Hauge CLA 2011-08-12 10:18:22 EDT
A quick glance at the code seems to indicate that we are comparing against all id mappings in the class hierarchy, but something must be going wrong.  Thanks for the test project.
Comment 4 elhanan Maayan CLA 2011-08-14 04:18:56 EDT
please note that i get an additional error of:

The type of the ID mapped by the relationship 'employee' does not agree with the primary key class of the target entity.
Comment 5 Neil Hauge CLA 2011-08-18 18:25:06 EDT
After reviewing the example, it would appear to me that the error is correct, in that the MapsId isn't referring to an attribute used for the Id of the entity.  I don't have your DB schema so perhaps there is something I'm missing, but I would expect the mapsId on JobHistory for the employee attribute to be defined as:

@MapsId("employeeId")

The MapsId should be mapping an identifier attribute from the JobHistory entity (not the Employee entity), which in this case is defined by JobHistoryPK:

@EmbeddedId
private JobHistoryPK id;

JobHistoryPK defines the employeeId attribute, which is what I would guess the MapsId should be mapping.

If there is some other Hibernate specific usage going on here, then they may need to customize this validation for their platform.  Otherwise, if I am not understanding your use case correctly, please explain a bit more how you are expecting this mapping to work.
Comment 6 elhanan Maayan CLA 2011-08-19 11:46:45 EDT
sorry my bad it works now
Comment 7 Neil Hauge CLA 2011-08-19 11:48:13 EDT
Marking as not a bug.