persistence@glassfish.java.net

Re: _at_OrderBy with Set

From: Guy Pelletier <guy.pelletier_at_oracle.com>
Date: Fri, 27 Feb 2009 08:32:59 -0500

Might not be the ideal solution, but try:

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

Cheers,
Guy
  ----- Original Message -----
  From: Gary Jacobson
  To: persistence_at_glassfish.dev.java.net
  Sent: Friday, February 27, 2009 6:04 AM
  Subject: @OrderBy with Set


  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