you can additionally annotate the relationship to specify an order for collections in 1-to-many or many-to-many relationships. Have a look at the documentation for the "@OrderBy" annotation I hope this is what you're looking for...
Joined: May 14, 2007
Thanks for reply.
However, is @OrderBy annotation needs extra column on Unit entity?
Because there is some Unit entity that doesn't belong to any UnitCollection, maybe this wouldn't be good......
You don't have to change the Unit entity class. The @OrderBy annotation just takes an attribute/column which should be used to sort the collection. Additionally you can choose to sort the collection elements in ascending or descending order. But that's up to you to define what kind of order makes sense for these Unit objects...
Joined: May 14, 2007
Thanks for reply again.
Because my client should be able to change order freely regardless of other columns in Unit entity, maybe I could use something @OrderBy("unitListOrder ASC").
However, is this means there should be column "unitListOrder" in Unit entity?
As far as I know the @OrderBy annotation requires that there is an existing column/attribute with the name you give it.
From the short description of your problem it seems to me that you want to allow the client to execute some kind of query. Perhaps you could simply wrap this query logic in another method which returns the Unit collection in the order(s) the client specified. Or you could do this queries in the database layer by providing some methods for the clients of your class which use the EJB query language. This would be a little bit more flexible than just the plain @OrderBy annotation.
Does that mean by specifying order by maintains its order - whenever data is retrieved in List. Or it can still change. For example I provide order by for bag and it will map to List. so whenever i access that list will it be always in same order?
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com