db-torque-user mailing list archives

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

Thanx a lot for cheering me up this morning, but I actually found a
solution for the problem.

This is how (my Extended BasePeer):
	public static long getNumberOfRowsInTable(String table, Criteria
c) throws TorqueException, DataSetException
	{
		c.addSelectColumn("COUNT(*)");
		String query = createQueryString(c);
		Log.debug("Query: " + query);
		c.getSelectColumns().clear();
		Log.debug("Query with original Criteria: " +
createQueryString(c));
		return
((Record)executeQuery(query).get(0)).getValue(1).asLong();
	}

I bet you see where the trick is ;)
(All the logs were just for debugging purposes)

P.S. Anyone interested in a lazy_paging macro for Globalmacros? And a
Patch for BasePeer to support this homegrown?

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: peter riegersperger [mailto:rick@subnet.at] 
Gesendet: Donnerstag, 13. Februar 2003 11:40
An: Turbine Torque Users List
Betreff: Re: AW: Copy criteria object


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

[...]
> > 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

apparently, Criteria does not implement clone().
if it cheers you up, you're not alone:
http://www.mail-archive.com/turbine-torque-user@jakarta.apache.org/msg01
480.html

(probably you find something useful for you in this thread)

i ended up working around this problem by creating a specific query for 
Counts, either with Criteria (it should work if you just use the
Criteria one 
time), or with the village objects themself.

rick


- -- 
|-
| peter riegersperger  <rick@subnet.at>
|-
| ein windows switcher tagebuch:  
|http://forum.subnet.at/viewforum.php?f=22
|-
| subnet
| platform for media art and experimental technologies
|-
| http://www.subnet.at/
|-
| muehlbacherhofweg 5 // 5020 salzburg // austria
|-
| fon/fax +43/662/842 897
|-
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)

iD8DBQE+S3X4IMP39JYOy9IRAh6YAKDYqPN9i23ZLVRWMi2WjJ93JQDfMgCfT9Ea
sj1QPXpekJEMzf2anbyMO9U=
=YFuR
-----END PGP SIGNATURE-----


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