RE: Multiple addJoin with OR

Thomas Fischer <[email protected]> Mon, 2 Mar 2009 14:26:48 +0100
Newsgroups gmane.comp.jakarta.turbine.torque.user
Message-ID <OF93F675E9.2B4FDFE3-ONC125756D.0049837E-C125756D.0049DD72@seitenbau.net>
> I want to create an SQLQuery that combines data from three tables. Right
> now, my javacode looks like this:
> 
> Criteria.addJoin(TableA.id, TableB.fk);
> Criteria.addJoin(TableA.id, TableC.fk);
> 
> This results in this SQL query: 
> 
> WHERE TableA.id = TableB.fk 
> 
> AND TableA.id = TableC.fk
> 
> However, this is not the result I need. What I need is a query with OR
> instead of AND, like this:
> 
> WHERE TableA.id = TableB.fk 
> 
> OR TableA.id = TableC.fk
> 
> I haven't found any way to do this using criteria. Is it possible?

I do not know a way to do this currently. But are you really sure your 
statement makes sense ? If one row in table B matches, then you get all 
rows of table C joined (or vice versa), and I cannot imagine this is what 
you need. But I might be wrong.

     Thomas