db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thomas Fischer <fisc...@seitenbau.net>
Subject RE: order by col1, col2 nulls first ??
Date Mon, 23 Jan 2006 09:12:32 GMT




"Garret O'Kelly" <garretokelly@beaumont.ie> schrieb am 20.01.2006 13:30:26:

> I'd like to use Oracles "order by ... nulls first"
> clause, but can't quite get it with Criteria. Any ideas?

Sorry , but I do not see any possibility to do this except creating a view
for this query and accessing the view. The reason is that the String
argument to addAscendingOrderByColumn is treated as a column name, even
with the spaces in it. This explains the sql for
criteria.addAscendingOrderByColumn("col2 nulls first");

On an afterthought, you could perhaps play a very bad trick and use a
logical expression where you replace the null by a string which will be
ordered to the beginning. I do not know the sql but in java pseudocode this
would be (I have used 'a' for the string which will be ordered to the
front, probably there are better choices)

criteria.addAscendingOrderByColumn("col2 == null ? 'a' : col2");

No idea whether this is possible a) in SQL and b) in Torque.

     Thomas

> What I want is
> ... order by col1, col2 asc nulls first
>
>
> I've tried
> criteria.addAscendingOrderByColumn(MyPeer.COL1);
> criteria.addAscendingOrderByColumn("col2 nulls first");
>
> but this gives:
> ... order by col1 asc, col2 nulls first asc
> which is invalid for Oracle
>
> I've also tried
> criteria.addAscendingOrderByColumn(MyPeer.COL1);
> criteria.getOrderByColumns.add("col2 nulls first asc");
>
> but that also gives an exception
>
> I'm using torque 3.0 btw
>
> ************************* D I S C L A I M E R *************************
>
> The opinions, conclusions and other information expressed in the
> above message, or contained within attachments to the above message,
> are not given or endorsed by Beaumont Hospital unless otherwise
> indicated by an authorised representative independent of this message.
>
> This e-mail message and any files transmitted with it are
> confidential and intended solely for the use of the individual or
> entity to whom they
> are addressed. If you have received this e-mail in error please notify
> the system manager.
>
> This e-mail has been scanned for viruses.
>
>
****************************************************************************

>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> For additional commands, e-mail: torque-user-help@db.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org


Mime
View raw message