db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thomas Mahler <thm...@web.de>
Subject Re: better support for subqueries
Date Sat, 13 Sep 2003 09:04:48 GMT
Hi Jakob,

+1 for adding it to CVS. I've also added some new and unplanned features 
(like the support for stored procedures).

Thomas

Jakob Braeuchi wrote:
> hi all,
> 
> i'm currently working on a better support for subqueries.
> these queries can now be used in place of attributes and subquery criteria
> can refer to attributes of the enclosing query (using the parentQuery. 
> prefix )
> 
> this query looks for all productgroups with more than 10 articles:
> 
>        ReportQueryByCriteria subQuery;
>        Criteria subCrit = new Criteria();
>        Criteria crit = new Criteria();
> 
>        
> subCrit.addEqualToField("productGroupId","parentQuery.groupId");   // 
> refer to enclosing query
>        subQuery = QueryFactory.newReportQuery(Article.class, subCrit);
>        subQuery.setColumns(new String[]{"count(productGroupId)"});
> 
>        crit.addGreaterThan(subQuery,"10");    // subquery as attribute
>        crit.addLessThan("groupId",new Integer(987654));
>        Query q = QueryFactory.newQuery(ProductGroup.class, crit);
> 
>        Collection results = broker.getCollectionByQuery(q);
> 
> the resulting sql is as follows:
> 
> SELECT A0.KategorieName,A0.Kategorie_Nr,A0.Beschreibung FROM Kategorien A0
> WHERE ((SELECT count(B0.Kategorie_Nr) FROM Artikel B0 WHERE 
> B0.Kategorie_Nr = A0.Kategorie_Nr) >  '10' )
> AND A0.Kategorie_Nr <  '987654'
> 
> i know we are feature complete for 1.0. so i ask _you_ whether i should 
> check it in or not ????
> 
> jakob
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-dev-help@db.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org


Mime
View raw message