db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jürgen Hoffmann ...@byteaction.de>
Subject Copy criteria object
Date Thu, 13 Feb 2003 09:32:42 GMT
Hi All,

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


Mime
View raw message