You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-user@db.apache.org by "Sperlich, Tino" <t....@hpc-hamburg.de> on 2004/03/02 09:16:54 UTC
AW: Torque, building Criteria for query ...
Hi Chris.
you have probably fixed the problem; but just for my info:
in the API of criteria there is a method like this
public Criteria addNotIn(java.lang.String column,
java.util.List values)
is there something wrong with this or would that do the job,
too?
Kind regards,
Tino Sperlich
-----Ursprüngliche Nachricht-----
Von: Chris Joelly [mailto:chris.joelly@unycom.com]
Gesendet: Freitag, 27. Februar 2004 16:02
An: Apache Torque Users List
Betreff: Re: Torque, building Criteria for query ...
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);
--
mit freundlichen Grüßen / with kind regards
Ing. Christian Jölly @ Solutions
unycom Information Technology Services GmbH
A-8042 Graz | Schmiedlstraße 1 / III
Tel: ++43 (0)316 / 818 828 - 30
Fax: ++43 (0)316 / 818 828 - 38
chris.joelly@unycom.com
http://www.unycom.com
Eine Frau kann vielleicht wunschlos glücklich sein, aber niemals
sprachlos glücklich.
-- Moritz Saphir
---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org
Re: AW: Torque, building Criteria for query ...
Posted by Chris Joelly <ch...@unycom.com>.
Hello!
yep. my problem was the surrounding {} ...
thx, Chris
Am Tue, Mar 02, 2004 at 09:37:41AM +0100, Kostyantyn Shchekotykhin meinte:
> with this method all is ok, the problem was that Chris wanted to add
> dicertly a List with Records and not Integers. When BasePeer composes
> query each Criterion value is converted to String. Village's
> Record.toString() is implemented so that each Record field is surrounded
> with {}. E.g. if it contains an Integer it will be something like "WHERE
> ID = {1000}".
>
> Sperlich, Tino wrote:
> >
> >you have probably fixed the problem; but just for my info:
> >in the API of criteria there is a method like this
> >
> >public Criteria addNotIn(java.lang.String column,
> > java.util.List values)
> >
> >is there something wrong with this or would that do the job,
> >too?
--
mit freundlichen Grüßen / with kind regards
Ing. Christian Jölly @ Solutions
unycom Information Technology Services GmbH
A-8042 Graz | Schmiedlstraße 1 / III
Tel: ++43 (0)316 / 818 828 - 30
Fax: ++43 (0)316 / 818 828 - 38
chris.joelly@unycom.com
http://www.unycom.com
Du warst noch nie 45 Minuten am Stück in einem Raum mit 30
pubertierenden Siebklässlern, die partout alles, was Du sagst,
zweideutig interpretieren wollen, gell?
-- Oliver Gassner
---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org
Re: AW: Torque, building Criteria for query ...
Posted by Kostyantyn Shchekotykhin <Ko...@ifit.uni-klu.ac.at>.
Hi Tino,
with this method all is ok, the problem was that Chris wanted to add
dicertly a List with Records and not Integers. When BasePeer composes
query each Criterion value is converted to String. Village's
Record.toString() is implemented so that each Record field is surrounded
with {}. E.g. if it contains an Integer it will be something like "WHERE
ID = {1000}".
Regards,
Kostya
Sperlich, Tino wrote:
> Hi Chris.
>
> you have probably fixed the problem; but just for my info:
> in the API of criteria there is a method like this
>
> public Criteria addNotIn(java.lang.String column,
> java.util.List values)
>
> is there something wrong with this or would that do the job,
> too?
>
> Kind regards,
>
> Tino Sperlich
>
>
>
> -----Ursprüngliche Nachricht-----
> Von: Chris Joelly [mailto:chris.joelly@unycom.com]
> Gesendet: Freitag, 27. Februar 2004 16:02
> An: Apache Torque Users List
> Betreff: Re: Torque, building Criteria for query ...
>
>
> 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