hi andreas,

i just added sub query support for in-criteria.
please have a look at the following testcase in class QueryTest:

ReportQueryByCriteria subQuery;
Criteria subCrit = new Criteria();
Criteria crit = new Criteria();
subQuery = QueryFactory.newReportQuery(Article.class, subCrit);
subQuery.setColumns(new String[] { "productGroupId" });
subQuery.setDistinct(true);
crit.addNotIn("groupId", subQuery);
Query q = QueryFactory.newQuery(ProductGroup.class, crit);
results = broker.getCollectionByQuery(q);

this will result in following sql:

SELECT A0.KategorieName,A0.Kategorie_Nr,A0.Beschreibung FROM Kategorien A0
WHERE A0.Kategorie_Nr NOT IN  (SELECT DISTINCT A0.Kategorie_Nr FROM Artikel
A0)

hth
jakob

----- Original Message -----
From: <[EMAIL PROTECTED]>
To: "OJB Users List" <[EMAIL PROTECTED]>
Sent: Friday, November 08, 2002 3:17 PM
Subject: Re: Re: Criteria.addIsNull doesn't work on 1:n and n:m relations


>
> hi jakob,
>
> is it possible to create this query on another way?
>
> thanks
> Andreas
>
>
>
>
>                     "Jakob
>                     Braeuchi"            An:     "OJB Users List"
<[EMAIL PROTECTED]>
>                     <jbraeuchi@gm        Kopie:
>                     x.ch>                Thema:  Re: Criteria.addIsNull
doesn't work on 1:n and n:m relations
>
>                     08.11.2002

>                     15:09
>                     Bitte
>                     antworten an
>                     "OJB Users
>                     List"
>
>
>
>
>
> hi andreas,
>
> the query does not work because 'adresses' is a relationship not a column;
> isNull works with columns only.
>
> hth
> jakob
>
> ----- Original Message -----
> From: <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Wednesday, November 06, 2002 1:10 PM
> Subject: Criteria.addIsNull doesn't work on 1:n and n:m relations
>
>
> > I have two classes, Person and Adress.
> >
> >   <class-descriptor class="Person"  table="PERSON_TABLE">
> >       <field-descriptor id="1" name="firstname" column="FIRSTNAME_TXT"
> > jdbc-type="VARCHAR" primarykey="true"  nullable="false" />
> >       <field-descriptor id="2" name="name" column="NAME_TXT" jdbc-type
> > ="VARCHAR" primarykey="true" nullable="false"/>
> >       <collection-descriptor name="adresses" element-class-ref="Adress"
> > auto-delete="true">
> >         <inverse-foreignkey field-id-ref="2"/>
> >         <inverse-foreignkey field-id-ref="3"/>
> >       </collection-descriptor>
> >   </class-descriptor>
> >
> >   <class-descriptor class="Adress" table="ADRESS_TABLE">
> >       <field-descriptor id="1" name="street" column="STREET_TXT"
> jdbc-type
> > ="VARCHAR" primarykey="true" nullable="false"/>
> >       <field-descriptor id="2" name="person_vname" column
> > ="PERSON_FIRSTNAME" jdbc-type="VARCHAR" />
> >       <field-descriptor id="3" name="person_nname" column="PERSON_NAME"
> > jdbc-type="VARCHAR"/>
> >   </class-descriptor>
> >
> >
> > I want to query all persons without a adress and get following
> > SQL-Statement:
> >
> > SELECT DISTINCT A0.FIRSTNAME_TXT,A0.NAME_TXT,A0 FROM PERSON_TABLE A0
> WHERE
> > adresses IS NULL
> >
> > This isn't correct, in the table PERSON_TABLE is no column adresses.
> >
> > Criteria criteria = new Criteria();
> > criteria.addIsNull("adresses");
> > Collection ret = pb.getCollectionByQuery(new
> QueryByCriteria(Person.class,
> > criteria, false));
> >
> > How could I fix this problem?
> > Thanks
> > Andy
> >
> >
> > --
> > To unsubscribe, e-mail:
<mailto:ojb-user-unsubscribe@;jakarta.apache.org
> >
> > For additional commands, e-mail:
<mailto:ojb-user-help@;jakarta.apache.org
> >
> >
>
>
> --
> To unsubscribe, e-mail:   <mailto:ojb-user-unsubscribe@;jakarta.apache.org>
> For additional commands, e-mail: <mailto:ojb-user-help@;jakarta.apache.org>
>
>
>
>
>
>
> --
> To unsubscribe, e-mail:   <mailto:ojb-user-unsubscribe@;jakarta.apache.org>
> For additional commands, e-mail: <mailto:ojb-user-help@;jakarta.apache.org>
>


--
To unsubscribe, e-mail:   <mailto:ojb-user-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail: <mailto:ojb-user-help@;jakarta.apache.org>

Reply via email to