Two problems that I see. A Collection is not necessarily ordered. So iterating through the collection does not mean that you are going to get the contents in any specific order. A List is an ordered collection so I would change the Collection to a List. This means that you need to ensure that you keep the objects in the List in order by ensuring that they are inserted into the correct location in the List from your code.
The second problem is that when the Entity manager populates the List from the persistent storage, it will not preserve the order in the List unless you add the "@OrderBy" annotation (or descriptor entry).
So change Collection<Objectattributes> to List<Objectattributes> and put in the @OrderBy annotation and you should be all set.
[Message sent by forum member 'bbergquist' (bbergquist)]
http://forums.java.net/jive/thread.jspa?messageID=235685