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 Marc
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 James
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 Oct 23 15:17:44 GMT 2014

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

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