db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Samuel Le Berrigaud <leber...@essi.fr>
Subject Re: How to create a join ?
Date Thu, 11 Dec 2003 13:32:22 GMT
You are right, I figured it out just after I sent the mail, should have 
think twice before sending it :-)

I don't know any way to have such a select with Torque, but you could 
probably do it with Two selects :

one for

T1.id_t1= T2.id_t1 AND T2.id_t3 = T3.id_t3

and one for

T1.id_t3 = T3.id_t3

And then the collection of objects you wanted is the "sum" of the 2 collections youn got this
way ...

Hope it helps ...

SaM


Cristian Zoicas wrote:

>On Thu, 11 Dec 2003, Samuel Le Berrigaud wrote:
>
>  
>
>>You may want to have a look at this page :
>>
>>http://db.apache.org/torque/peers-howto.html  (at the bottom of the page)
>>
>>the part named "Examples" seems to be what you want ...
>>
>>SaM
>>    
>>
>
>Thank  you anyway and without  being  offensive  but the example you
>pointed ( shown below ) is not exactly the same thing in my opinion.
>
>  
>
>>>>BEGIN EXAMPLE <<<<
>>>>        
>>>>
>
>    select * from abc where (a < 1 and b > 2) or (  a > 5  and b < 3)
>
>    Criteria crit = new Criteria();
>    Criteria.Criterion a1 = crit.getNewCriterion(ABC.A, 1, Criteria.LESS_THAN);
>    Criteria.Criterion b2 = crit.getNewCriterion(ABC.B, 2, Criteria.GREATER_THAN);
>    Criteria.Criterion a5 = crit.getNewCriterion(ABC.A, 5, Criteria.GREATER_THAN);
>    Criteria.Criterion b3 = crit.getNewCriterion(ABC.B, 3, Criteria.LESS_THAN);
>
>    crit.add(a1.and(b2).or(a5.and(b3)));
>
>  
>
>>>>END EXAMPLE <<<
>>>>        
>>>>
>
>Here are the reasons:
>
>  1. the FROM caluse contains only one table.
>  2. The getNewCriterion method allows you to add
>         a) a column name
>         b) a value
>         c) a comparison statement between the column name
>             and the value.
>
>     and I need a getCriterion which allows me to add :
>         a) a column name;
>         b) a column name;
>         c) a comparison statement between the columns.
>
>     Does torque lack such a method or is it possible to do it in
>     another way ?
>
>Cristian Zoicas
>
>
>
>
>
>  
>
>>Cristian Zoicas wrote:
>>
>>    
>>
>>>Hello all
>>>
>>>I've tried to figure out how to use the Criteria class in
>>>order to obtain a statement like
>>>
>>>SELECT
>>>      *
>>>FROM
>>>      T1, T2, T3
>>>WHERE
>>>      ( T1.id_t1= T2.id_t1 AND T2.id_t3 = T3.id_t3 )
>>>      OR
>>>      ( T1.id_t3 = T3.id_t3 )
>>>
>>>but I was not able to do it.
>>>Does anybody has any solution ?
>>>
>>>Thank you in advance
>>>Cristian Zoicas
>>>
>>>
>>>
>>>---------------------------------------------------------------------
>>>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
>>
>>
>>    
>>
>
>
>---------------------------------------------------------------------
>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