You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by Martin Ludeiro <ma...@gmail.com> on 2010/07/22 19:45:42 UTC
Ordering expression
I want to do an ordering expression with two columns, but i cant find
the way
The generated SQL must be something like "SELECT A, B FROM T ORDER BY A
+ B";
Sorry for my bad english
Thanks in advance
Re: Ordering expression
Posted by Andrus Adamchik <an...@objectstyle.org>.
EJBQLQuery will support that. I really hope we reconcile it with
SelectQuery, as now it has to be created from String.
Andrus
On Jul 22, 2010, at 9:19 PM, Mike Kienenberger wrote:
> Sorry, I misread your question. You really want to do an ordering by
> expression rather than by column.
>
> There is a thread on this.
>
> http://mail-archives.apache.org/mod_mbox/cayenne-user/201003.mbox/%3Cdc5d39031003152211pad3d1advc5bb5c34562fbc62@mail.gmail.com%3E
>
> The short answer is that it's not supported. There are a number of
> workarounds, depending on the specific query and how you need to use
> it.
>
> In your specific case, perhaps you could create a view containing A+B
> as an additional column and sort on that column.
>
> Or you can use an SQLTemplate to create the query.
>
> I believe there were other workarounds in the thread above.
>
>
> On Thu, Jul 22, 2010 at 2:13 PM, Mike Kienenberger
> <mk...@gmail.com> wrote:
>> http://cayenne.apache.org/doc30/using-orderings.html
>>
>> On Thu, Jul 22, 2010 at 1:45 PM, Martin Ludeiro
>> <ma...@gmail.com> wrote:
>>> I want to do an ordering expression with two columns, but i cant
>>> find
>>> the way
>>>
>>> The generated SQL must be something like "SELECT A, B FROM T ORDER
>>> BY A
>>> + B";
>>>
>>> Sorry for my bad english
>>> Thanks in advance
>>>
>>
>
Re: Ordering expression
Posted by Mike Kienenberger <mk...@gmail.com>.
Sorry, I misread your question. You really want to do an ordering by
expression rather than by column.
There is a thread on this.
http://mail-archives.apache.org/mod_mbox/cayenne-user/201003.mbox/%3Cdc5d39031003152211pad3d1advc5bb5c34562fbc62@mail.gmail.com%3E
The short answer is that it's not supported. There are a number of
workarounds, depending on the specific query and how you need to use
it.
In your specific case, perhaps you could create a view containing A+B
as an additional column and sort on that column.
Or you can use an SQLTemplate to create the query.
I believe there were other workarounds in the thread above.
On Thu, Jul 22, 2010 at 2:13 PM, Mike Kienenberger <mk...@gmail.com> wrote:
> http://cayenne.apache.org/doc30/using-orderings.html
>
> On Thu, Jul 22, 2010 at 1:45 PM, Martin Ludeiro
> <ma...@gmail.com> wrote:
>> I want to do an ordering expression with two columns, but i cant find
>> the way
>>
>> The generated SQL must be something like "SELECT A, B FROM T ORDER BY A
>> + B";
>>
>> Sorry for my bad english
>> Thanks in advance
>>
>
Re: Ordering expression
Posted by Mike Kienenberger <mk...@gmail.com>.
http://cayenne.apache.org/doc30/using-orderings.html
On Thu, Jul 22, 2010 at 1:45 PM, Martin Ludeiro
<ma...@gmail.com> wrote:
> I want to do an ordering expression with two columns, but i cant find
> the way
>
> The generated SQL must be something like "SELECT A, B FROM T ORDER BY A
> + B";
>
> Sorry for my bad english
> Thanks in advance
>