Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » @OneToMany SortedSet
@OneToMany SortedSet [message #741657] Wed, 19 October 2011 15:15 Go to next message
Marc  is currently offline Marc
Messages: 12
Registered: September 2011
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 #748405 is a reply to message #741657] Mon, 24 October 2011 13:23 Go to previous messageGo to next message
James Sutherland is currently offline James Sutherland
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
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 : Wiki : Book : Blog : Twitter
Re: @OneToMany SortedSet [message #755063 is a reply to message #748405] Mon, 07 November 2011 04:15 Go to previous message
Pedro Jos is currently offline Pedro Jos
Messages: 2
Registered: November 2011
Junior Member
Quote:
The problem is that i'm getting the following compile time error :
Target entity for "manyA" is not defined.


Had the same problem. In my case I need to add the import, ┬┐do you have import java.util.TreeSet?
Previous Topic:Partition - id on new entities?
Next Topic:Audit trail
Goto Forum:
  


Current Time: Thu Jul 24 09:10:04 EDT 2014

Powered by FUDForum. Page generated in 0.68505 seconds