Hi Marc,
In my Case:
Com.workingdogs.village.Record r =
WebserverDailyPeer.executeQuery(Criteria).get(0);
long rows = r.getValue(1).asLong();
Kind regards
Jürgen Hoffmann
ByteACTION GmbH
cert. Perl Programmer
cert. Linux System Administrator
cert. Java Programmer
Besuchen Sie uns doch auf der CeBIT 2003
in Halle 4/Stand 70
-----Ursprüngliche Nachricht-----
Von: Marc Lustig [mailto:mail@marclustig.com]
Gesendet: Donnerstag, 13. Februar 2003 10:35
An: Torque Users List
Betreff: AW: Copy criteria object
Jürgen, I have a general question regarding your sql-construction. Did
you ever got the count(*) function working using
myCrit.addSelectColumn("COUNT(*)");
?
What Peer-method do you call to retrieve the result?
If you call doSelect(c) on the Peer how would Torque be able to map the
result delivered by your db?
COUNT(*) doesn't return any field-names, but only the number.
I myself have realized the COUNT(*) task by hard-coding a JDBC
Statement.
Gruss
Marc
> -----Ursprüngliche Nachricht-----
> Von: Jürgen Hoffmann [mailto:jh@byteaction.de]
> Gesendet: Donnerstag, 13. Februar 2003 09:02
> An: turbine-user@jakarta.apache.org
> Betreff: Copy criteria object
>
>
> Hi All,
>
> I am sending this question to this list, because I am receiving
> MAILER-DAEMONS when following the subscription links to the
> torque-user mailinglists from the torque website.
>
> Here is my Problem:
>
> I have a criteria Object that I build like this:
>
> cri.add(cri.getNewCriterion(WebserverDailyPeer.DAY, (Object)
> ("(UNIX_TIMESTAMP(" + WebserverDailyPeer.DAY + ") between " +
> (von_date / 1000) + " and " + (bis_date / 1000) + " )"),
> Criteria.CUSTOM)); cri.add(WebserverDailyPeer.KID, kdid);
>
>
> So when i run the
> Log.debug(WebserverDailyPeer.createQueryString(cri));
> I get:
> SELECT FROM webserver_daily WHERE
> (UNIX_TIMESTAMP(webserver_daily.DAY)
> between 1009839600 and 1041375600 ) AND webserver_daily.KID=3
>
> Which is correct. Then I want to use a "copy" of the criteria object
> and modify it like this: myCrit = cri.clone();
> myCrit.addSelectColumn("COUNT(*)");
> Log.debug(WebserverDailyPeer.createQueryString(cri));
>
> But then I get:
> SELECT COUNT(*) FROM webserver_daily WHERE
> webserver_daily.DAY='(UNIX_TIMESTAMP(webserver_daily.DAY) between
> 1009839600 and 1041375600 )' AND webserver_daily.KID=3
> ^^^^^^^^^^^^^^^^^^^^^
>
> Which is incorrect!!!
>
> Then I tried to just copy the hashtable, but same effect: Criteria
> myCrit = new Criteria(); Enumeration e = cri.keys();
> while (e.hasMoreElements())
> {
> Object key = e.nextElement();
> myCrit.put(key, cri.get(key));
> }
>
> Can someone help me, please?
>
> Mit freundlichen Grüssen
>
> Jürgen Hoffmann
> ByteACTION GmbH
>
> cert. Perl Programmer
> cert. Linux System Administrator
> cert. Java Programmer
>
> Besuchen Sie uns doch auf der CeBIT 2003
> in Halle 4/Stand 70
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-user-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org
|