Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 324770 - Validation error needed for nested ElementCollection
Summary: Validation error needed for nested ElementCollection
Status: REOPENED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P2 enhancement with 2 votes (vote)
Target Milestone: ---   Edit
Assignee: Nobody - feel free to take it CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-09-08 13:14 EDT by Karen Butzke CLA
Modified: 2022-06-09 10:24 EDT (History)
3 users (show)

See Also:


Attachments
exception stack trace (4.88 KB, text/plain)
2010-09-08 13:14 EDT, Karen Butzke CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Karen Butzke CLA 2010-09-08 13:14:44 EDT
Created attachment 178424 [details]
exception stack trace

Given the following example attempt to generate DDL and you get the attached exception and the tables are not generated. Looks like this exception would happen just logging in and initializing descriptors. I am testing with 2.2.0 M2

@Entity
public final class PropertyRecord {
    @EmbeddedId
    PropertyOwner owner;

    @AttributeOverrides({
        @AttributeOverride(name="key.street", column=@Column(name="STREET")),
	@AttributeOverride(name="value.size", column=@Column(name="SQ_FEET")),
	@AttributeOverride(name="value.tax", column=@Column(name="TAX")),})
    @ElementCollection
    Map<Address, PropertyInfo> parcels;
}

@Embeddable
public class Address {
    protected String street;
    protected int city;
    @ElementCollection
    protected Collection<Zipcode> zipcode;
}

@Embeddable
public class Zipcode {
    protected String zip;
    protected String plusFour;
}

@Embeddable
public class PropertyInfo {
    Integer parcelNumber;
    Integer size;
    BigDecimal tax;
}

@Embeddable
public class PropertyOwner {
    private String name;
}
Comment 1 Guy Pelletier CLA 2010-10-28 11:08:41 EDT
This is not supported by spec, section 2.6.

"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. (See Section 2.9.)"

When the feature was being developed, there were discussions surrounding this and we decided not to provide support above and beyond the spec in this case.
Comment 2 Karen Butzke CLA 2011-03-10 07:59:11 EST
I am reopening this as the exception you get with this use case is so difficult to decipher. We should be giving a validation error that the Embeddable cannot contain an ElementCollection
Comment 3 Tom Ware CLA 2011-03-10 09:23:30 EST
Resetting target and priority.  Current opinion is that this is a fringe case.
Comment 4 Mathias Schaefer CLA 2012-05-15 11:24:06 EDT
I stumpled over this exception while testing the new nosql (mongodb) support coming with Eclipse Juno.

In my opinion this is not an fringe case anymore - at least for the usage of nosql databases. This is now an ordinary use case and so this problem might become a real show stopper.
Comment 5 Tom Ware CLA 2012-05-15 11:30:13 EDT
Changing to an enhancement request.  Please vote for it if it is important to you.
Comment 6 Eclipse Webmaster CLA 2022-06-09 10:14:08 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink
Comment 7 Eclipse Webmaster CLA 2022-06-09 10:24:06 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink