db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ludwig Magnusson" <lud...@itcatapult.com>
Subject RE: Multiple addJoin with OR
Date Mon, 02 Mar 2009 13:33:44 GMT
I thougt of that as well and it generates a InvocationTargetException that has a NullPointerException.
I ran it through a debug but could not find the source..

-----Original Message-----
From: Hidde Boonstra [Us Media] [mailto:hidde.boonstra@usmedia.nl] 
Sent: den 2 mars 2009 14:18
To: Apache Torque Users List
Subject: Re: Multiple addJoin with OR

Hi Ludwig,

never done that, but I would suppose you could use criteria.getNewCriterion and use the SqlEnum.JOIN
as your comparison. Than use criteria.criterion.or to create an or between the two.

See:

http://db.apache.org/torque/releases/torque-3.3/runtime/apidocs/org/apache/torque/util/Criteria.html

http://db.apache.org/torque/releases/torque-3.3/runtime/apidocs/org/apache/torque/util/SqlEnum.html

http://db.apache.org/torque/releases/torque-3.3/runtime/apidocs/org/apache/torque/util/Criteria.Criterion.html

Regards,

Hidde.

----- "Ludwig Magnusson" <ludwig@itcatapult.com> wrote:

> Hi!
> 
> 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?
> 
> /Ludwig

-- 
Hidde Boonstra
Us Media B.V.
Stadhouderskade 115
1073 AX Amsterdam

t: 020 428 68 68
f: 020 470 69 05
www.usmedia.nl

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


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


Mime
View raw message