You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by "Harisinganey, Mohnish" <Mo...@kraft.com> on 2004/06/10 19:53:21 UTC

RE: OJB - Query for two table join

I have this exact same issue.
How do you speify the join with the ReportQueryByCriteria.

thanks in advance
Mohnish

-----Original Message-----
From: Info [mailto:info@crestax.ca]
Sent: Thursday, April 22, 2004 1:00 PM
To: OJB Users List
Subject: Re: OJB - Query for two table join


Enrique Medina wrote:

> Hi Wallace,
>
> You have to use a ReportQueryByCriteria() where you can specify which 
> attributes you want OJB to return instead of a getCollection(). 
> Following your example:
>
> Criteria crit = new Criteria();
>
> // Set criterias ...
> crit.addEqualTo(...);
>
> // Create the report query.
> ReportQueryByCriteria q = QueryFactory.newReportQuery(A.class, crit);
>
> // You can also ask for aggregate functions (SUM(A.xxx)) ...
> q.setAttributes(new String[] {"A.xxx", "A.yyy", "B.zzz" });
>
> // And you can set 'orderBy' and 'groupBy' clauses ...
> q.addGroupBy("A.xxx");
> ...
> q.addOrderBy("B.zzz");
> ...
>
> return broker.getReportQueryIteratorByQuery(q); // which returns an 
> Object[]
>
> Hope it helps you,
> Enrique Medina.
>
>> From: Info <in...@crestax.ca>
>> Reply-To: info@crestax.ca
>> To: ojb-user@db.apache.org
>> Subject: OJB - Query for two table join
>> Date: Thu, 22 Apr 2004 01:21:37 -0400
>>
>> Hi,
>>
>> For example, I have two table A and B. Now I want a combination 
>> collection of some field of A and some of B:
>>
>> SELECT A.xxx, A.yyy, B.zzz
>> FROM A
>> INNER JOIN B
>> ON A.id = B.id
>>
>> I will get a colleciton as a result after open a query by using OJB, 
>> but how can I get the data (xxx, yyy, zzz) from a Collection?
>> If OJB does not support this feature, any alternetive solutions 
>> available right now?
>>
>>
>> Thanks,
>>
>> Wallace
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>
>
> _________________________________________________________________
> ¿Dónde se esconden l@s solter@s? Encuentra miles de perfiles en MSN 
> Amor & Amistad. http://match.msn.es/
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>
>
>
>
Wonderful! You reply help me a lot!

Thanks!
Wallace

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

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