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

Bug 325920

Summary: Eclipse Editor highlights relationships used in compound primary keys as incorrect
Product: [WebTools] Dali JPA Tools Reporter: welljim
Component: GeneralAssignee: dali.general-inbox <dali.general-inbox>
Status: CLOSED DUPLICATE QA Contact:
Severity: normal    
Priority: P3 CC: neil.hauge, tom.ware
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:

Description welljim CLA 2010-09-21 22:37:53 EDT
Build Identifier:  20100218-1602


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 Tom Ware CLA 2010-09-23 13:30:59 EDT
This bug should be filed under Dali in the WebTools project.  I have sent an FYI to one of the Dali committers, but it would be safer for you to  refile with the correct project than to assume this will get picked up.

I was not able to figure out how to correctly edit the Product.
Comment 2 Neil Hauge CLA 2010-09-23 16:58:09 EDT
Re-assigning to Dali project.
Comment 3 Neil Hauge CLA 2010-09-23 16:59:24 EDT
What version of the Eclipse IDE are you using?
Comment 4 Neil Hauge CLA 2010-09-23 17:05:08 EDT
Re-closing.  Didn't realize that bug was already re-entered as requested.

*** This bug has been marked as a duplicate of bug 326093 ***