persistence@glassfish.java.net

_at_OrderBy with Set

From: Gary Jacobson <gtjacobson_at_gmail.com>
Date: Fri, 27 Feb 2009 13:04:05 +0200

I have an entity which contains the following field:

    @OneToMany( cascade = CascadeType.ALL, mappedBy = "sale" )
    @OrderBy( value = "sequence" )
    private Set<SalePurchaser> salePurchaserSet = new
TreeSet<SalePurchaser>();

Unfortunately the internal Set implementation
(oracle.toplink.essentials.indirection.IndirectSet) is not a SortedSet, so
the @OrderBy has no effect.

You cannot specify SortedSet or TreeSet for the field type.

Is there any workaround for this? I'd prefer to avoid using a List if
possible.

Thanks
Gary