persistence@glassfish.java.net

Re: Maintaining an order of the list

From: Gary Jacobson <gtjacobson_at_gmail.com>
Date: Wed, 17 Oct 2007 12:18:38 +0200

Hi Aleksei

Why not add an "index" field to the Item?

Then you could simply iterate through the list and set the index for each
Item, and specify @OrderBy( value = "index" ) to make sure the list is
retrieved in that same order.

I would guess that you could also make Item implement Comparable, and use a
sorted collection like TreeSet, but I haven't tested this.

Regards
Gary