persistence@glassfish.java.net

Re: Maintaining an order of the list

From: Aleksei Valikov <aleksei.valikov_at_gmail.com>
Date: Mon, 15 Oct 2007 23:44:30 +0200

Hi.

> The List in the JPA1.0 spec, even if annotated with @OrderBy, is not guaranteed
> to be ordered at all times if the users in their code don't maintain the order
> themselves:
>
> > 9.1.28 OrderBy Annotation
> >
> > The OrderBy annotation specifies the ordering of the elements of a collection
> > valued association at the point when the association is *retrieved*.

Thanks, I see.

> I'm not sure if a Map can guarantee the order either :(.

Well, yes. I was thinking of something like


Map<Integer, T> resultMap = ...;
for (int index = 0; index < list.size(); index++)
{resultMap.put(index, list.get(index);}

in getter and the reverse think in setter.

All in all, JPA 1.0 seems to be very limited. I'll direct my comments
to the spec leads, I hope they care.

Bye.
/lexi