Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

EclipseLink: @ElementCollection from embeddable object

PuceJan 21 2010 — edited Jan 22 2010
Hi,

I already asked this question in the EclipseLink forum:
[http://www.eclipse.org/forums/index.php?t=msg&th=160045&start=0&|http://www.eclipse.org/forums/index.php?t=msg&th=160045&start=0&]

but since the problem is not solved yet and EclipseLink is the reference implementation of JPA 2.0, I'm cross-posting here.

I need a list of Strings inside an embeddable object:

@Embeddable
public class Foo{
@ElementCollection
private List<String> bars = new ArrayList<String>();
}

but I get a NoSuchElementException ([EclipseLink-28018])

User James of the EclipseLink forum said this is probably a bug, so I filed one here:
[https://bugs.eclipse.org/bugs/show_bug.cgi?id=298830|https://bugs.eclipse.org/bugs/show_bug.cgi?id=298830]

He also mentioned that there could be some work-arounds with either using a @JoinColumn on the @CollectionTable and setting the primary key column from the parent or defining the mapping in code using the EclipseLink DirectCollectionMapping through a DescriptorCustomizer.

I tried various combinations but couldn't get it to work.

Has someone already successfully done such a mapping? Can you show a sample? You can find my test case showing the problem here, which you could modify:
[https://bugs.eclipse.org/bugs/attachment.cgi?id=156393|https://bugs.eclipse.org/bugs/attachment.cgi?id=156393]

-Puce
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 19 2010
Added on Jan 21 2010
4 comments
459 views