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 Info <in...@crestax.ca> on 2004/04/23 20:32:05 UTC
Code in two table join
Hello,
I tried the following code to select a join, but get error:
Criteria crit = new Criteria();
crit.addEqualToColumn("A.xxx", "B.xxx");
ReportQueryByCriteria q =
QueryFactory.newReportQuery(A.class, crit);
q.setAttributes(new String[] {"A.xxx", "A.yyy", "B.zzz" });
Iterator it = broker.getReportQueryIteratorByQuery(q);
( In the case, for string "A.xxx" or "B.zzz", what name should I use as
A or B? The physical table name or class name represented or other name?)
SQL statement:
SELECT A.xxx, A.yyy, B.zzz
FROM A JOIN B
ON A.xxx = B.xxx
Please help!
Thanks!
Wallace
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
Re: Code in two table join
Posted by Jakob Braeuchi <jb...@gmx.ch>.
hi wallace,
it's not necessary to join manually, ojb will do it for you:
Criteria crit = new Criteria();
ReportQueryByCriteria q = QueryFactory.newReportQuery(A.class, crit);
q.setAttributes(new String[] {"xxx", "yyy", "rel_b.zzz" });
Iterator it = broker.getReportQueryIteratorByQuery(q);
there must be a relationship-definition from class A to B named 'rel_b' in the
repository.
jakob
Info wrote:
> Hello,
>
> I tried the following code to select a join, but get error:
>
>
> Criteria crit = new Criteria();
> crit.addEqualToColumn("A.xxx", "B.xxx");
> ReportQueryByCriteria q =
> QueryFactory.newReportQuery(A.class, crit);
> q.setAttributes(new String[] {"A.xxx", "A.yyy",
> "B.zzz" });
>
> Iterator it = broker.getReportQueryIteratorByQuery(q);
>
> ( In the case, for string "A.xxx" or "B.zzz", what name should I use as
> A or B? The physical table name or class name represented or other name?)
> SQL statement:
>
> SELECT A.xxx, A.yyy, B.zzz
> FROM A JOIN B
> ON A.xxx = B.xxx
>
> Please help!
>
> 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