db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Asaf Shakarchi" <a...@raytech.co.il>
Subject Question regarding Criterias
Date Mon, 17 Oct 2005 20:20:00 GMT
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.

 

 

 


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message