HIbernate actually handles this.
When you define a relationship as a list, hibernate ensures that the
items are always fetched in the same order.
I haven't dug into the details of how to do this. I know its possible
to explicitly declare a "sort column", but generally unnecessary;
I assume that in the absence of an explicit sort column, hibernate
(silently) adds a sort column for you.
I can check into how they handle the non-explicit-ordering-column case
if you'd like.
Interestingly, by default, a one-to-many relationship in hibernate is
still handled through an intermediary join table.
You can override that, of course, but I thought it a curious default.
That said, by silently handling relationships that way,
it would allow them to add the sort information to the join table,
which has no object corollary so your object model is uncluttered.
On Sep 26, 2008, at 9/269:48 AM , Andrus Adamchik wrote:
> On Sep 26, 2008, at 2:41 AM, Chris Murphy wrote:
>> Wouldn't it be a good idea for the generated methods to have the
>> extra int argument?
> It is a bit more involved than that. The problem with including this
> in Cayenne is that it won't work in a more general case. E.g. if you
> add an object at a particular index, and the master object is later
> invalidated and refetched, the order will be lost. Or if it is
> refetched by another user. So Scott's answer was essentially correct.
> We tried to solve it from another angle, by defining a certain
> column as the "ordering" column to instruct Cayenne to order fetched
> relationship lists. It is still on the table, but it is also hairy...
> For now I can't think of a clean generic solution that would map to
> a DB. The ordering column is the closest I can think of.
This archive was generated by hypermail 2.0.0 : Fri Sep 26 2008 - 11:01:53 EDT