Bug 381040 - ValidationException extending from (nested) ElementCollection aggregate
Summary: ValidationException extending from (nested) ElementCollection aggregate
Status: NEW
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: PC Linux
: P2 major (vote)
Target Milestone: ---   Edit
Assignee: Nobody - feel free to take it CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-05-30 09:27 EDT by Mathias Schaefer CLA
Modified: 2022-06-09 10:30 EDT (History)
2 users (show)

See Also:


Attachments
exception stack trace (8.22 KB, text/plain)
2012-05-30 09:28 EDT, Mathias Schaefer CLA
no flags Details
example maven project (for glassfish deployment) (8.43 KB, application/zip)
2012-05-30 09:30 EDT, Mathias Schaefer CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Mathias Schaefer CLA 2012-05-30 09:27:21 EDT
Build Identifier: 

Given the following example and attempt to deploy this you will get the attached exception. I looks like nested/inherited ElementCollections using mongodb are in fact working fine, but extending from a base class which has an (nested) ElementCollection member is prohibited.
I'm testing with latest nightly builds (20120528) and patched glassfish v4.

I know, that this exception is fired because this behaviour is not covered by the current JPA spec. However, as v2.1 doesn't cover the nosql topic at all it should be allowed at least for those non relational datasources.
I mentioned this already in a similar case here https://bugs.eclipse.org/bugs/show_bug.cgi?id=324770.

Short example to make clear what I'm talking about:

/* THIS DOESN'T WORK */

@Embeddable
public class Address {    
    protected String street;
    protected String country;
}

@Embeddable
public class Employee {
    @ElementCollection
    protected List<Address> adresses = new ArrayList<Address>();
}

@MappedSuperclass
public class ExtensibleEmployeeBase {
    @Id
    @GeneratedValue
    @Field(name="_id")
    protected String id;

    @ElementCollection
    protected List<Employee> employees = new ArrayList<Employee>();
}

@Entity
public class Company extends ExtensibleEmployeeBase  {
    /* additional stuff here... */
}


/* THIS WORKS */

@Embeddable
public class Address {    
    protected String street;
    protected String country;
}

@Embeddable
public class Employee {
    @ElementCollection
    protected List<Address> adresses = new ArrayList<Address>();
}

@Embeddable
public class ExtensibleEmployeeBase {
    @Id
    @Field(name="_id")
    protected String id;

    @ElementCollection
    protected List<Employee> employees = new ArrayList<Employee>();
}

@Entity
public class Company {
    @Id
    @GeneratedValue
    @Field(name="_id")
    protected String id;

    @Embedded
    protected ExtensibleEmployeeBase employeeBase;

    /* additional stuff here... */
}

So I guess this problem can be fixed by removing this exception at least for the case of an nosql datasource.

Reproducible: Always

Steps to Reproduce:
1. create sample project
2. deploy (e.g. on glassfish) (fails)
Comment 1 Mathias Schaefer CLA 2012-05-30 09:28:18 EDT
Created attachment 216476 [details]
exception stack trace
Comment 2 Mathias Schaefer CLA 2012-05-30 09:30:40 EDT
Created attachment 216477 [details]
example maven project (for glassfish deployment)
Comment 3 Mathias Schaefer CLA 2012-05-30 09:32:53 EDT
One additional comment regarding my previous example:
note that I have replaced @MappedSuperclass with @Embeddable and embedded my ExtensibleEmployeeBase instead if inheriting from it.
Comment 4 Tom Ware CLA 2012-07-04 08:15:29 EDT
Setting target and priority.  See the following page for the meanings of these fields:

http://wiki.eclipse.org/EclipseLink/Development/Bugs/Guidelines

Community: Please vote for this bug if it is important to you.  Votes are one of the main criteria we use to determine which bugs to fix next.
Comment 5 Eclipse Webmaster CLA 2022-06-09 10:30:31 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink