Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » @OneToMany SortedSet
@OneToMany SortedSet [message #741659] Wed, 19 October 2011 19:15 Go to next message
Marc is currently offline MarcFriend
Messages: 25
Registered: July 2009
Junior Member
In order to guarantee preserving the order after any add/remove operation, I'm trying to use a TreeSet attribute under a jpa project as follows :

@OneToMany(mappedBy="b")
private TreeSet<A> manyA;

'A' does implement the Comparable<A> interface.

The problem is that i'm getting the following compile time error :
Target entity for "manyA" is not defined.

If i replace TreeSet by Set the error disappears, i tried the SortedSet interface but still having the same error.

I'm using eclipselink 2.3.0, and Eclipse EE IDE Indigo.

Is there any way to make eclipseLink accept SortedSet mapped attributes?
Re: @OneToMany SortedSet [message #748406 is a reply to message #741659] Mon, 24 October 2011 17:23 Go to previous message
James is currently offline JamesFriend
Messages: 272
Registered: July 2009
Senior Member
Is this a compile error, or just a warning from Eclipse's JPA support?

If you just ignore the warning, does it work?

You can give the targetEntity in the annotation and probably make the warning go away.

JPA only allows Collection, List and Set for collection types, but EclipseLink will support any implementation is you use EAGER. For LAZY support, one of the three interfaces is currently required. You could use Set, and assign a TreeSet to it, however EclipseLink would use its LAZY Set, IndirectSet when restoring from the database.

So try,
@OneToMany(targetEntity=A.class, fetch=EAGER, mappedBy="b")


--
James : http://wiki.eclipse.org/EclipseLink : http://en.wikibooks.org/wiki/Java_Persistence : http://java-persistence-performance.blogspot.com/
Previous Topic:Problem persisting TimestampTZ with JPA
Next Topic:command line tool for generating JPA Entities?
Goto Forum:
  


Current Time: Thu Apr 25 04:15:31 GMT 2024

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

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

Back to the top