db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kostyantyn Shchekotykhin <Kostyantyn.Shchekotyk...@ifit.uni-klu.ac.at>
Subject Re: Torque, building Criteria for query ...
Date Fri, 27 Feb 2004 16:29:49 GMT
Hi Chris,
when a createQueryString method composes a query it gets all values of 
Criterions as Strings calling value.toString();

a Record.toString() will result a string like this "{'1000'}" (see 
toString() method of Record). If you have questions about Record and why 
toString() is made this way, send a message to one of the Village folks.

Regards,
Kostya


Chris Joelly wrote:

> Hi Kostya!
> 
> i managed to use the following code for the query:
> 
> 	Criteria critEreignisse = new Criteria();
> 	critEreignisse.setDistinct();
> 	critEreignisse.addSelectColumn(EreignisPeer.DATEITYP_ID);
> 	critEreignisse.add(EreignisPeer.INT_IAKZ, int_iakz);
> 	
> 	List dateitypIds = BasePeer.doSelect(critEreignisse);
> 	Iterator i = dateitypIds.iterator();
> 				
> 	int[] dt = new int[dateitypIds.size()];
> 	
> 	for (int c = 0; c < dateitypIds.size(); c++) {
> 		 dt[c] = ((Record) dateitypIds.get(c)).getValue(1).asInt();
> 	}
> 	
> 	Criteria critDateitypen = new Criteria();
> 	critDateitypen.addNotIn(Dateityp2aktenartPeer.DATEITYP_ID, dt);
> 
> as you can see i use the addNotIn method to add an int[], but why can't
> i use the addNotIn method with the returned List itself?
> 
> eg: critDateitypen.addNotIn(Dateityp2aktenartPeer.DATEITYP_ID, dateitypIds);
> 
> thx, Chris
> 
> Am Fri, Feb 27, 2004 at 09:54:23AM +0100, Kostyantyn Shchekotykhin meinte:
> 
>>Criteria object doesn't support inner queries, because not all databases 
>>support them. So you can try something this like this, but remember that 
>>this solution highly depends on your database:
>>
>>        Criteria criteria = new Criteria();
>>        criteria.setDistinct();
>>        criteria.addSelectColumn(YourPeer.COL1);
>>        criteria.add(YourPeer.COL2, "value1");
>>        Criteria criteria2 = new Criteria();
>>        criteria2.add(YourPeer2.COL1, (Object)(YourPeer2.COL1 + " NOT 
>>IN " + BasePeer.createQueryString(criteria)), Criteria.CUSTOM);
>>        YourPeer2.doSelect(criteria2);
> 
> 

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