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

Bug 347368

Summary: UnsupportedOperationException when element collection contains nested relationship mapping using JoinTable strategy
Product: [WebTools] Dali JPA Tools Reporter: Nan Li <nan.n.li>
Component: JPAAssignee: Karen Butzke <karenfbutzke>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: jolene.moffitt, karenfbutzke, neil.hauge
Version: unspecifiedFlags: neil.hauge: review+
Target Milestone: 3.0.2   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Attachments:
Description Flags
Stack Trace
none
proposed patch against 3.0 maintenance
none
proposed patch against 3.0 maintenance none

Description Nan Li CLA 2011-05-26 16:22:34 EDT
Build Identifier: I20110519-1138

1. Define type mappings as the following:

@Entity
public class Phone {
	@Id
	private String type;
	private Integer num;
}

@Embeddable
public class EmbeddableType {

	@JoinTable(name= "Emp_Phone") <- uses JoinTable strategy
	@ManyToOne
	private Phone phone;
}

@Entity
public class Employee {

	@ElementCollection
	private Collection<EmbeddableType> emType;
}

2. Create a mapping file and add the entity Employee to it

3. Right-click the attribute "emType" of Employee entity in the JPA structure pane and add it to the mapping xml

4. Select phone(Association Override) under Value section in the JPA Deatils view and then select "Override default" checkbox

Save the changes and a UnsupportedOperationException will be thrown saying
 
java.lang.UnsupportedOperationException: An element collection containing a nested relationship mapping using a JoinTable is not supported 

A full stack trace is attached. A couple of things needs to be considered here:

1. If we don't support JoinTable strategy, we should hide association mappings using this strategy from the "Attribute overrides" list or disable the "Override default" checkbox to prevent users from overriding these association mappings.
2. We'd better give users a validation message instead of an exception. 

Reproducible: Always
Comment 1 Nan Li CLA 2011-05-26 16:23:50 EDT
Created attachment 196705 [details]
Stack Trace
Comment 2 Neil Hauge CLA 2011-07-01 16:25:36 EDT
Moving JPA specific bugs to new JPA component in bugzilla.
Comment 3 Karen Butzke CLA 2011-11-01 10:34:36 EDT
I have removed the UnsupportedOperationException. Bug 325162 will be used to add the validation for this case.
Comment 4 Karen Butzke CLA 2011-11-01 10:42:14 EDT
Created attachment 206269 [details]
proposed patch against 3.0 maintenance
Comment 5 Karen Butzke CLA 2011-11-01 10:43:47 EDT
Created attachment 206270 [details]
proposed patch against 3.0 maintenance
Comment 6 Karen Butzke CLA 2011-11-01 10:44:26 EDT
I've attached a patch for fixing this in 3.0.2
Comment 7 Karen Butzke CLA 2011-11-01 11:27:33 EDT
fix checked in to maintenance
Comment 8 Jolene Moffitt CLA 2011-11-22 10:13:18 EST
Verified in Build M-3.3.2-20111117045640

Verified the UnsupportedOperationException does not appear when you check the override default checkbox and Save the project.  See the link to view test steps for verification. http://wiki.eclipse.org/Dali_3.0.2