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:[EMAIL PROTECTED]
Sent: Thursday, October 23, 2003 6:31 PM
To: [EMAIL PROTECTED]
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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]






---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to