db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Maurice Wijtten <...@lucka.nl>
Subject Re: Problems with Criteria and ORDER BY
Date Thu, 23 Oct 2003 10:42:30 GMT
Why don't just use       criteria.addSelectColumn("count(" + 
PeerName.fieldconstant + ")");
The field constants usually include the tablename. (usually you'll be 
able to find a column as
a substitute for the * sign).

Maurice Wijtten


Amit Rana wrote:

>Use criteria.addSelectColumn("count(*)"); to add count(*)
>Use tablePeer. doSelectVillageRecords(criteria) to retrieve records
>
>then you can fetch the value from the list.
>
>HTH
>
>  
>
>>-----Original Message-----
>>From: Michael Burschik [mailto:Burschik@lotto-berlin.de]
>>Sent: Thursday, October 23, 2003 6:31 PM
>>To: torque-user@db.apache.org
>>Subject: Problems with Criteria and ORDER BY
>>
>>The BasePeer.createQuery method checks whether the order by column
>>    
>>
>contains
>  
>
>>a "." and throws an exception if it does not. This is not a very good
>>    
>>
>idea.
>  
>
>>First of all, it does not catch non-existent column names that happen
>>    
>>
>to
>  
>
>>include a ".". And secondly, it does not allow for the perfectly legal
>>    
>>
>use
>  
>
>>of a column alias in the order by statement, e.g. "select somecolumn,
>>count(*) as count from mytable order by count". Is there another way
>>    
>>
>to get
>  
>
>>this, apart from the obvious solution of building the statement
>>    
>>
>manually?
>  
>
>>Regards
>>
>>Michael Burschik
>>
>>
>>---------------------------------------------------------------------
>>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
>
>
>  
>


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