Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 325162 - [Validation] Embeddable class contained within an element collection must not a contain an element collection
Summary: [Validation] Embeddable class contained within an element collection must not...
Status: RESOLVED FIXED
Alias: None
Product: Dali JPA Tools
Classification: WebTools
Component: JPA (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows XP
: P3 enhancement (vote)
Target Milestone: 3.2 M6   Edit
Assignee: Leslie Davis CLA
QA Contact:
URL:
Whiteboard: JPA2.0 fix_ready
Keywords: plan
Depends on:
Blocks:
 
Reported: 2010-09-13 16:29 EDT by Karen Butzke CLA
Modified: 2012-05-24 16:14 EDT (History)
1 user (show)

See Also:
karenfbutzke: review+


Attachments
proposed bug fix patch (16.94 KB, patch)
2011-03-02 14:47 EST, Leslie Davis CLA
les.davis: review+
Details | Diff
test project (15.23 KB, application/x-sdlc)
2011-03-10 08:14 EST, Karen Butzke CLA
no flags Details
patch with additional recommended changes (17.66 KB, patch)
2011-03-10 14:50 EST, Leslie Davis CLA
no flags Details | Diff
patch with additional recommended changes (18.63 KB, text/plain)
2011-03-11 18:13 EST, Leslie Davis CLA
no flags Details
proposed patch (32.42 KB, patch)
2012-02-21 14:59 EST, Leslie Davis CLA
no flags Details | Diff
updated patch (32.96 KB, patch)
2012-02-21 17:08 EST, Leslie Davis CLA
neil.hauge: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Karen Butzke CLA 2010-09-13 16:29:57 EDT
See section 2.6 of the spec: An embeddable class (including an embeddable class within another embeddable class) contained within an element collection must not contain an element collection, nor may it contain a relationship to an entity other than a many-to-one or one-to-one relationship. The embeddable class must be on the owning side of such a relationship and the relationship must be mapped by a foreign key mapping.

EclipseLink does not support these use cases either.
Comment 1 Leslie Davis CLA 2011-03-02 14:47:25 EST
Created attachment 190194 [details]
proposed bug fix patch

Attached a proposed bug fix for this issue.
Comment 2 Karen Butzke CLA 2011-03-10 08:14:15 EST
Created attachment 190850 [details]
test project

I have attached a test project that should have a validation error when this bug is fixed. Les, your current patch does not give a validation error. I'm not sure why I didn't attach this project when I wrote up the bug in the first place
Comment 3 Karen Butzke CLA 2011-03-10 09:40:11 EST
Not sure if this matters, but EclipseLink is considering this a fringe case and has targeted it to future. they do not have a validation error for it, and ddl generation fails with an odd exception, see bug 324770
Comment 4 Leslie Davis CLA 2011-03-10 14:50:57 EST
Created attachment 190910 [details]
patch with additional recommended changes

Added validation for mapped key embeddedable
Comment 5 Karen Butzke CLA 2011-03-11 11:50:12 EST
Neil and I have come up with some changes to the validation messages. My element collection mapping testing looks good so far, will continue testing the relationship mapping use case.

Mapping contains an embeddable \"{0}\" with a prohibited mapping "\"{1}\". Element collections may not contain embeddables with element collection mappings.


Mapping contains an embeddable \"{0}\" with a prohibited mapping "\"{1}\".  Embeddables in element collections may only contain many-to-one or one-to-one mappings and must be on the \"owning\" side of the relationship.
Comment 6 Leslie Davis CLA 2011-03-11 18:13:23 EST
Created attachment 191033 [details]
patch with additional recommended changes
Comment 7 Neil Hauge CLA 2011-04-21 13:00:45 EDT
Deferring since this is considered a fringe case.  This should be checked in after branching for 3.1.
Comment 8 Neil Hauge CLA 2011-07-01 16:23:21 EDT
Moving JPA specific bugs to new JPA component in bugzilla.
Comment 9 Karen Butzke CLA 2011-08-16 08:27:09 EDT
These validation messages need corresponding virtual validation messages. If you add the PropertyRecord entity to an orm.xml file and don't specify the attribute mappings, you will see the same validation message and you can't tell which attribute it is referring to.

Also need to add the validation messages to the validation preferences (see JpaProblemSeveritiesPage)
Comment 10 Karen Butzke CLA 2011-11-01 10:26:54 EDT
This example is from bug 347368, we need to cover this case with validation as well.

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;
}
Comment 11 Leslie Davis CLA 2012-02-21 14:59:20 EST
Created attachment 211360 [details]
proposed patch

Added virtual validation messages, problems preferences, and addition validation case for JoinTable.
Comment 12 Leslie Davis CLA 2012-02-21 17:08:05 EST
Created attachment 211374 [details]
updated patch
Comment 13 Karen Butzke CLA 2012-02-27 11:57:08 EST
checked in for M6