db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lti-1...@myamail.com
Subject Re: Question regarding Criterias
Date Tue, 18 Oct 2005 15:28:55 GMT
Asaf Shakarchi wrote:

>Hey,
>
> 
>
>I'm new to Torque, just finished the installation and I have a little
>question which probably is obvious for most of you ;)
>
> 
>
> 
>
>Assuming I have two tables 'field' table which is built as: 'field_id',
>'field_name'
>
>And another table named 'field_connector' which is built as:
>'field_connector_id', 'field_id1','field_id2'
>
> 
>
>I'd like to end with a query such as:
>
> 
>
>SELECT * FROM field WHERE field_connector.FIELD_ID1= field.FIELD_ID OR
>field_connector.FIELD_ID2 = field.FIELD_ID
>
> 
>
>I tried to do this by the following code:
>
> 
>
>Criteria crit = new Criteria();
>
>Criteria.Criterion linkFieldConnectorToField1=
>crit.getNewCriterion(FieldConnectorPeer.FIELD_ID1, FieldPeer.FIELD_ID,
>Criteria.EQUAL);
>
>Criteria.Criterion linkFieldConnectorToField2=
>crit.getNewCriterion(FieldConnectorPeer.FIELD_ID2, FieldPeer.FIELD_ID,
>Criteria.EQUAL);
>
>Criteria.Criterion linkBothFieldConnectorToField=
>linkFieldConnectorToField1.or(linkFieldConnectorToField2);
>
> 
>
> 
>
>But it seems that the query that is built makes a WHERE condition where
>fieldConnector.FIELD_ID1='field.FIELD_ID', of course it fails since the
>expression equals a field name to a string (obviously because of the '')
>
> 
>
> 
>
>I thought about using JOIN here, but JOINS always add one join to another
>with AND between each JOIN.and I'd like to have an expression here with OR
>condition.
>
> 
>
> 
>
>Is there any way to do it?
>
> 
>
> 
>
>Thanks in advanced,
>
> 
>
>Asaf.
>  
>
Could you post the whole code (Criteria building AND the doSelect ...)
and the complete SQL query that is generated ?
Thanks.

---------------------------------------------------------------------
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