Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 347368 - UnsupportedOperationException when element collection contains nested relationship mapping using JoinTable strategy
Summary: UnsupportedOperationException when element collection contains nested relatio...
Status: VERIFIED FIXED
Alias: None
Product: Dali JPA Tools
Classification: WebTools
Component: JPA (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: 3.0.2   Edit
Assignee: Karen Butzke CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-05-26 16:22 EDT by Nan Li CLA
Modified: 2011-11-22 10:13 EST (History)
3 users (show)

See Also:
neil.hauge: review+


Attachments
Stack Trace (5.42 KB, text/plain)
2011-05-26 16:23 EDT, Nan Li CLA
no flags Details
proposed patch against 3.0 maintenance (6.48 KB, patch)
2011-11-01 10:42 EDT, Karen Butzke CLA
no flags Details | Diff
proposed patch against 3.0 maintenance (7.51 KB, patch)
2011-11-01 10:43 EDT, Karen Butzke CLA
no flags Details | Diff

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