db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Carlos Olmos" <carlosol...@eudoramail.com>
Subject Re: Aggregates
Date Wed, 26 Mar 2003 16:33:30 GMT
 Remember to use "AccountTransactionPeer.doSelectVillageRecords(c)" instead of the "doSelect()"

Also, remember that VillageRecord datasets are 1 based, so use "record.getValue(1).asInt()"

greetings.

carlos olmos.


--

On Mon, 24 Mar 2003 18:17:44  
 Seth Milder wrote:
>Hi everyone,
>
>What is a good way to do aggregates? I saw the thread about count(*), 
>but it does not seem to work. This is what I am trying now:
>
>	Criteria c = new Criteria();
>	c.addSelectColumn("COUNT(ID)");
>	c.addGroupByColumn("ID");
>	c.add(AccountTransactionPeer.FOO_ID, getId());
>
>	try {
>	    List result = AccountTransactionPeer.doSelect(c);
>	    Record rec = (Record) result.get(0);
>	    int count = rec.getValue(0).asInt();
>	    if (log.isDebugEnabled()) {
>		log.debug("getting transaction counts NUM -> " + count);
>	    }
>	    return count;
>	} catch (Exception e) {
>	    e.printStackTrace();
>	    return -1;
>	}
>
>Which produces this exception:
>
>org.apache.torque.TorqueException: Malformed column name in Criteria 
>select: 'COUNT(ID)' is not of the form 'table.column'
>
>Anyone know the proper way to do this? Do I have to use 
>BasePeer.executeQuery() ?
>
>-- 
>Seth Milder
>Department of Physics and Astronomy
>MS 3f3
>George Mason University
>Fairfax, VA
>http://www.mrseth.org
>--
>To invent, you need a good imagination and a pile of junk. -- Thomas Edison
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
>For additional commands, e-mail: torque-user-help@db.apache.org
>
>


Need a new email address that people can remember
Check out the new EudoraMail at
http://www.eudoramail.com

Mime
View raw message