You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by Fredrik Liden <fl...@translate.com> on 2007/12/05 21:06:17 UTC

Ordering using fields from multiple objects

Hi,

Does anyone have any advice on how to order on fields that span more
than one table? If I have 

Object1
Field1
Field2
object2 [reference to 1 object 2]

Object2
Field1
Field2

I'm retrieving a list of Object 1 objects but I would like sort on the
fields in Object 2 as well.

Is there any chance that the following would work? 

orderings.add(new Ordering("object2.Field", true));

Or do I need to create a raw sql query?

Thanks,

Fredrik

Re: Ordering using fields from multiple objects

Posted by Robert Zeigler <ro...@puregumption.com>.
Your orderings.add statement should work just fine.

Robert

On Dec 5, 2007, at 12/52:06 PM , Fredrik Liden wrote:

> Hi,
>
> Does anyone have any advice on how to order on fields that span more
> than one table? If I have
>
> Object1
> Field1
> Field2
> object2 [reference to 1 object 2]
>
> Object2
> Field1
> Field2
>
> I'm retrieving a list of Object 1 objects but I would like sort on the
> fields in Object 2 as well.
>
> Is there any chance that the following would work?
>
> orderings.add(new Ordering("object2.Field", true));
>
> Or do I need to create a raw sql query?
>
> Thanks,
>
> Fredrik