db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jakob Braeuchi <jbraeu...@gmx.ch>
Subject Re: [vote] reference to a parent attribute in subquery
Date Fri, 29 Aug 2003 18:13:45 GMT
hi all,

any ideas regarding this topic ?

jakob

Jakob Braeuchi wrote:

> hi all,
>
> i'm working on subquery attributes referencing an attribute in parent 
> query.
> the problem is how prefix those attributes in a way not causing 
> problems with relationship names ?
>
> super.attributeOfParentQuery  ?
> parent.attributeOfParentQuery  ?
> enclosing.attributeOfParentQuery  ?
> or any other prefix
>
>
>
> sample:
>
>        ReportQueryByCriteria subQuery;
>        Criteria subCrit = new Criteria();
>        Criteria crit = new Criteria();
>
>        subCrit.addEqualToField("productGroupId","super.groupId");   << 
> refer to attribute of enclosing query
>        subQuery = QueryFactory.newReportQuery(Article.class, subCrit);
>        subQuery.setColumns(new String[]{"count(productGroupId)"});
>
>        crit.addLessThan("10", subQuery);     // MORE than 10 articles
>        Query q = QueryFactory.newQuery(ProductGroup.class, crit);
>
> this results in the following sql:
>
> SELECT A0.KategorieName,A0.Kategorie_Nr,A0.Beschreibung FROM 
> Kategorien A0 WHERE 10 <  (SELECT count(B0.Kategorie_Nr) FROM Artikel 
> B0 WHERE B0.Kategorie_Nr = A0.Kategorie_Nr)
>
>
> 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