db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "andres@rizo.net" <and...@rizo.net>
Subject Re: How to use column in order by that does not exist in table?
Date Tue, 10 Feb 2004 15:38:59 GMT

This issue has arised many, many times. Check old posts, there is a patch 
you need to do to BasePeer class

---------- Original Message -----------
From: "Michael Schmitt" <mi.schmitt@gmx.de>
To: <torque-user@db.apache.org>
Sent: Tue, 10 Feb 2004 13:24:46 +0100
Subject: How to use column in order by that does not exist in table?

> Hi,
> I am trying to do something like the following:
> 
>   SELECT band_id, MAX(date_inserted) FROM 
>   band_comment GROUP BY band_id ORDER BY 2
> 
> or
> 
>   SELECT band_id, MAX(date_inserted) AS inserted FROM 
>   band_comment GROUP BY band_id ORDER BY inserted
> 
> I am using a Criteria in the following way:
> 
>   Criteria c = new Criteria();
> 
>   c.addSelectColumn(CommentPeer.BAND_ID);
>   c.addAsColumn("inserted","MAX(" + CommentPeer.DATE_INSERTED + ")");
> 
>   c.addAscendingOrderByColumn("inserted");
> 
>   List comments = BasePeer.doSelect(c);
> 
> Executing this, a TorqueException will be thrown with the message:
>   Malformed column name in Criteria order by: 
>   'inserted ASC' is not of the form 'table.column'
>   
> 
> Does anyone know how to use a column in the 'order by' clause that
> does not exist in the table?
> 
> greetings,
> michael
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> For additional commands, e-mail: torque-user-help@db.apache.org
------- End of Original Message -------


---------------------------------------------------------------------
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