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 Ben Hall <be...@hpdsoftware.com> on 2005/01/21 01:55:01 UTC

Additional outer join criteria

Hi,

Is it possible within OJB to specify additional criteria in (outer) joins ?
If so, can anyone point me at some examples ?

I'd like to do something similar to this:

SELECT A0.NAME, A2.NAME FROM TABLE0 A0

LEFT OUTER JOIN TABLE1 A1 ON A0.TABLE1ID = A1.ID 
LEFT OUTER JOIN TABLE2 A2 ON A1.TABLE2ID = A2.ID AND A2.VALUE < 10

Thanks,
Ben.



___________________________________________________________
HPD Software Ltd. - Helping Business Finance Business
Email terms and conditions: www.hpdsoftware.com/disclaimer 



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


Re: Additional outer join criteria

Posted by Bobby Lawrence <ro...@jlab.org>.
Ben -
I have used joins directly in the repository.xml file to specify 
multiple tables for one class.
Ex.

<class-descriptor class="myClass"
                      table="people left join usernames on 
usernames.person_id = people.person_id">
 </class-descriptor>

It works for me.....give it a try.....
--Bobby


Ben Hall wrote:

>Hi,
>
>Is it possible within OJB to specify additional criteria in (outer) joins ?
>If so, can anyone point me at some examples ?
>
>I'd like to do something similar to this:
>
>SELECT A0.NAME, A2.NAME FROM TABLE0 A0
>
>LEFT OUTER JOIN TABLE1 A1 ON A0.TABLE1ID = A1.ID 
>LEFT OUTER JOIN TABLE2 A2 ON A1.TABLE2ID = A2.ID AND A2.VALUE < 10
>
>Thanks,
>Ben.
>
>
>
>___________________________________________________________
>HPD Software Ltd. - Helping Business Finance Business
>Email terms and conditions: www.hpdsoftware.com/disclaimer 
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>For additional commands, e-mail: ojb-user-help@db.apache.org
>
>  
>

-- 
----------------------------
Bobby Lawrence
MIS Application Developer

Jefferson Lab (www.jlab.org)

 Email: robertl@jlab.org
Office: (757) 269-5818
 Pager: (757) 584-5818
----------------------------





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


Re: Additional outer join criteria

Posted by Jakob Braeuchi <jb...@gmx.ch>.
hi ben,

ojb buils the joins based on the foreignkey fields in the repository. 
there are no other fields used for joins.

hth
jakob

Ben Hall schrieb:
> Hi,
> 
> Is it possible within OJB to specify additional criteria in (outer) joins ?
> If so, can anyone point me at some examples ?
> 
> I'd like to do something similar to this:
> 
> SELECT A0.NAME, A2.NAME FROM TABLE0 A0
> 
> LEFT OUTER JOIN TABLE1 A1 ON A0.TABLE1ID = A1.ID 
> LEFT OUTER JOIN TABLE2 A2 ON A1.TABLE2ID = A2.ID AND A2.VALUE < 10
> 
> Thanks,
> Ben.
> 
> 
> 
> ___________________________________________________________
> HPD Software Ltd. - Helping Business Finance Business
> Email terms and conditions: www.hpdsoftware.com/disclaimer 
> 
> 
> 
> ---------------------------------------------------------------------
> 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


Re: Additional outer join criteria

Posted by Danilo Tommasina <dt...@risksys.com>.
Hi you probably mean something like this:

SELECT A0.NAME, A2.NAME FROM TABLE0 A0
LEFT OUTER JOIN TABLE1 A1 ON A0.TABLE1ID = A1.ID
LEFT OUTER JOIN TABLE2 A2 ON A1.TABLE2ID = A2.ID
WHERE A2.VALUE < 10

With PersistenceBroker API this can be done using a ReportQueryByCriteria:

ex:

Criteria c1 = new Criteria();
c1.addLessThan( "<pathFromTable0ToTable1>.<pathFromTable1ToTable2>.value", new Integer( 10 ) );

ReportQueryByCriteria query = new ReportQueryByCriteria( Table0.class, new String [] { "name", "<pathFromTable0ToTable1>.<pathFromTable1ToTable2>.name" } );

// Then get a PersistenceBroker instance, extract values using getReportQueryIteratorByQuery(...) and close the PersistenceBroker

bye
Danilo

> Hi,
> 
> Is it possible within OJB to specify additional criteria in (outer) joins ?
> If so, can anyone point me at some examples ?
> 
> I'd like to do something similar to this:
> 
> SELECT A0.NAME, A2.NAME FROM TABLE0 A0
> 
> LEFT OUTER JOIN TABLE1 A1 ON A0.TABLE1ID = A1.ID 
> LEFT OUTER JOIN TABLE2 A2 ON A1.TABLE2ID = A2.ID AND A2.VALUE < 10
> 
> Thanks,
> Ben.
> 
> 
> 
> ___________________________________________________________
> HPD Software Ltd. - Helping Business Finance Business
> Email terms and conditions: www.hpdsoftware.com/disclaimer 
> 
> 
> 
> ---------------------------------------------------------------------
> 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