Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » @ElementCollection from embeddable object
@ElementCollection from embeddable object [message #505612] Sun, 03 January 2010 14:55 Go to next message
Florian Brunner is currently offline Florian BrunnerFriend
Messages: 9
Registered: January 2010
Junior Member
Hi,

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])

Is it possible to use an @ElementCollection inside an embeddable object?
Do I have to specify the PK of the parent entity somehow?

-Florian

---------------------
Exception in thread "main" Local Exception Stack:
Exception [EclipseLink-30005] (Eclipse Persistence Services - 2.0.0.v20091127-r5931): org.eclipse.persistence.exceptions.PersistenceUnitLoadingExc eption
Exception Description: An exception was thrown while searching for persistence archives with ClassLoader: sun.misc.Launcher$AppClassLoader@19134f4
Internal Exception: javax.persistence.PersistenceException: Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.0.0.v20091127-r5931): org.eclipse.persistence.exceptions.EntityManagerSetupExcepti on
Exception Description: Predeployment of PersistenceUnit [myproject] failed.
Internal Exception: java.util.NoSuchElementException
at org.eclipse.persistence.exceptions.PersistenceUnitLoadingExc eption.exceptionSearchingForPersistenceResources(Persistence UnitLoadingException.java:126)
at org.eclipse.persistence.jpa.PersistenceProvider.createEntity ManagerFactory(PersistenceProvider.java:133)
at org.eclipse.persistence.jpa.PersistenceProvider.createEntity ManagerFactory(PersistenceProvider.java:65)
at javax.persistence.Persistence.createEntityManagerFactory(Per sistence.java:78)
at javax.persistence.Persistence.createEntityManagerFactory(Per sistence.java:54)
at myproject.core.TestMain.main(TestMain.java:26)
Caused by: javax.persistence.PersistenceException: Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.0.0.v20091127-r5931): org.eclipse.persistence.exceptions.EntityManagerSetupExcepti on
Exception Description: Predeployment of PersistenceUnit [myproject] failed.
Internal Exception: java.util.NoSuchElementException
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl. predeploy(EntityManagerSetupImpl.java:986)
at org.eclipse.persistence.internal.jpa.deployment.JPAInitializ er.callPredeploy(JPAInitializer.java:88)
at org.eclipse.persistence.jpa.PersistenceProvider.createEntity ManagerFactory(PersistenceProvider.java:124)
... 4 more
Caused by: Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.0.0.v20091127-r5931): org.eclipse.persistence.exceptions.EntityManagerSetupExcepti on
Exception Description: Predeployment of PersistenceUnit [myproject] failed.
Internal Exception: java.util.NoSuchElementException
at org.eclipse.persistence.exceptions.EntityManagerSetupExcepti on.predeployFailed(EntityManagerSetupException.java:210)
... 7 more
Caused by: java.util.NoSuchElementException
at java.util.AbstractList$Itr.next(AbstractList.java:350)
at org.eclipse.persistence.internal.jpa.metadata.MetadataDescri ptor.getPrimaryKeyField(MetadataDescriptor.java:837)
at org.eclipse.persistence.internal.jpa.metadata.MetadataDescri ptor.getPrimaryKeyFieldName(MetadataDescriptor.java:846)
at org.eclipse.persistence.internal.jpa.metadata.accessors.mapp ings.ElementCollectionAccessor.processCollectionTable(Elemen tCollectionAccessor.java:663)
at org.eclipse.persistence.internal.jpa.metadata.accessors.mapp ings.DirectCollectionAccessor.process(DirectCollectionAccess or.java:264)
at org.eclipse.persistence.internal.jpa.metadata.accessors.mapp ings.DirectCollectionAccessor.processDirectCollectionMapping (DirectCollectionAccessor.java:305)
at org.eclipse.persistence.internal.jpa.metadata.accessors.mapp ings.ElementCollectionAccessor.process(ElementCollectionAcce ssor.java:638)
at org.eclipse.persistence.internal.jpa.metadata.MetadataProjec t.processDirectCollectionAccessors(MetadataProject.java:1021 )
at org.eclipse.persistence.internal.jpa.metadata.MetadataProjec t.processStage3(MetadataProject.java:1356)
at org.eclipse.persistence.internal.jpa.metadata.MetadataProces sor.processORMMetadata(MetadataProcessor.java:462)
at org.eclipse.persistence.internal.jpa.deployment.PersistenceU nitProcessor.processORMetadata(PersistenceUnitProcessor.java :390)
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl. predeploy(EntityManagerSetupImpl.java:940)
... 6 more
Java Result: 1
Re: @ElementCollection from embeddable object [message #505753 is a reply to message #505612] Mon, 04 January 2010 18:59 Go to previous messageGo to next message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

This should be possible, so seems to be a bug. Please log the bug. It should use the embeddables parent's primary key.

You could try giving a @JoinColumn on the @CollectionTable and setting the primary key column from the parent.

You could also define the mapping in code using the EclipseLink DirectCollectionMapping through a DescriptorCustomizer.


James : Wiki : Book : Blog : Twitter
Re: @ElementCollection from embeddable object [message #505843 is a reply to message #505753] Tue, 05 January 2010 10:28 Go to previous messageGo to next message
Florian Brunner is currently offline Florian BrunnerFriend
Messages: 9
Registered: January 2010
Junior Member
Hi James,

thnaks for your answer.

I filed a bug here:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=298830

Feel free to vote for it. Smile

I'll try the other things you mentioned and see if I can use them as a work around.
Re: @ElementCollection from embeddable object [message #508394 is a reply to message #505612] Mon, 18 January 2010 16:09 Go to previous messageGo to next message
Florian Brunner is currently offline Florian BrunnerFriend
Messages: 9
Registered: January 2010
Junior Member
Hi James,

I couldn't make it work with @CollectionTable or DescriptorCustomizer.

Can you (or someone else) show me a sample?

Eg. I added a test case to the issue:

https://bugs.eclipse.org/bugs/attachment.cgi?id=156393
https://bugs.eclipse.org/bugs/show_bug.cgi?id=298830

Thanks a lot!
Re: @ElementCollection from embeddable object [message #509087 is a reply to message #508394] Thu, 21 January 2010 11:22 Go to previous messageGo to next message
Florian Brunner is currently offline Florian BrunnerFriend
Messages: 9
Registered: January 2010
Junior Member
I also cross-posted this question in the Sun Java forum:
http://forums.sun.com/thread.jspa?messageID=10911108&#10 911108
Re: @ElementCollection from embeddable object [message #509205 is a reply to message #505612] Thu, 21 January 2010 16:42 Go to previous message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

What did you try with the CollectionTable or DescriptorCustomizer and what error did you get?


James : Wiki : Book : Blog : Twitter
Previous Topic:Rules for equals and hashcode methods for an entity
Next Topic:doesn't find method definition!!!!!
Goto Forum:
  


Current Time: Fri Mar 29 04:36:39 GMT 2024

Powered by FUDForum. Page generated in 0.05383 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top