You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-dev@db.apache.org by Jakob Braeuchi <jb...@gmx.ch> on 2003/09/12 23:57:01 UTC
better support for subqueries
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
Re: better support for subqueries
Posted by Jakob Braeuchi <jb...@gmx.ch>.
hi thomas,
i checked it in. so far so good.
but some other files not belonging to this change were also checked in
(by my or eclipse's mistake i think :( )
i replaced those files by the previous revisions, because i do not know
how to delete a wrong revision. i hope these revisions do not cause any
inconvenience.
sorry
jakob
Thomas Mahler wrote:
> 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
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org
Re: better support for subqueries
Posted by Thomas Mahler <th...@web.de>.
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
Re: better support for subqueries
Posted by Brian McCallister <mc...@forthillcompany.com>.
Assuming it doesn't break existing...
+1 checkin but don't document it for 1.0
It can be part of the spiffy 1.1 that is released a week after 1.0 ;-)
-Brian
On Friday, September 12, 2003, at 05:57 PM, 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