Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 326093 - Eclipse Editor highlights relationships used in compound primary keys as incorrect
Summary: Eclipse Editor highlights relationships used in compound primary keys as inco...
Status: CLOSED INVALID
Alias: None
Product: Dali JPA Tools
Classification: WebTools
Component: General (show other bugs)
Version: 2.1   Edit
Hardware: All Mac OS X - Carbon (unsup.)
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: dali.general-inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 325920 (view as bug list)
Depends on:
Blocks:
 
Reported: 2010-09-23 15:25 EDT by welljim CLA
Modified: 2010-09-23 19:16 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description welljim CLA 2010-09-23 15:25:57 EDT
Build Identifier: 20100218-1602 (Glassfish v3.0, upgraded with EclipseLink 2.1)

Assume 2 tables that are comprised of compound Primary Keys. Also, part of the
PK of table 2 is a FK of table 1. The following example illustrates this case:

DEPARTMENT
----------
ID -> (PK)
DEVISION_ID -> (PK)


PROJECT
--------
DEPT_ID -> (PK, FK)
DEVISION_ID -> (PK, FK)
NAME -> (PK)



Given that part of Project's PK is also a FK to Department (i.e., a project can
only be created under an existing department), this is mapped like so:

@Entity 
@IdClass(ProjectId.class)
public class Project {
    @Id
    @ManyToOne
    private Department dept;

    @Id
    private String name;

    // ...
}

public class ProjectId implements Serializable {
    private String name;
    private DeptId dept;

    public ProjectId() {}
    // ...
}

@Entity 
@IdClass(DeptId.class)
public class Department {
    @Id
    private int id;

    @Id
    private int devisionId;


    @OneToMany(mappedBy = "dept")
    private List<Project> projects;

    // ...
}

public class DeptId implements Serializable {
    private int id;
    private int devisionId;

    public DeptId() {}
    // ...
}



This works correctly when run in Glassfish v3.0 with EclipseLink 2.1, however
the Eclipse editor insists on underlining with red the annotation "@id" of
field "dept" in class "Project". Hovering the mouse over the underline brings
up the message "Column 'dept' cannot be resolved". In class Department, the
editor underlines the mappedBy name ("dept") with the message "Attribute named
'dept' has invalid mapping for this relationship".



Reproducible: Always

Steps to Reproduce:
1. Recreate the tables and entities described above
2. Notice that the Eclipse editor underlines the @Id and mappedBy as incorrect
3. Populate the table with some random data and run the configuration in
Glassfish or other compatible engine
4. The configuration runs as expected, and all find(), merge(), remove()
operations work without a problem
Comment 1 Karen Butzke CLA 2010-09-23 16:20:14 EDT
In Dali 2.1 we did not support JPA 2.0. Derived identities support was added in the JPA 2.0 spec. You will have to try Dali 2.2 or 2.3 to get JPA 2.0 support.
Comment 2 Neil Hauge CLA 2010-09-23 17:05:08 EDT
*** Bug 325920 has been marked as a duplicate of this bug. ***
Comment 3 Karen Butzke CLA 2010-09-23 17:08:30 EDT
I just realized that you're using version 2.1 of EclipseLink, so not sure what
version of Dali you are using. Possibly you just need to go to the Project
preferences, choose 'Project Facets' and change the version of the JPA facet to
2.0. Then you can change the platform to EclipseLink 2.1. If you don't have the
option of changing the JPA facet version to 2.0 then you need to upgrade Dali
Comment 4 welljim CLA 2010-09-23 19:16:12 EDT
Just upgraded Dali as per Karen's instructions and the problem is resolved.

Thanks.