Hey, Thanks for answering,
Are there any details of how addSelectColumn works? I don't see anything related to it by the link you've specified nor anything else related, can you point me to something more specific? Thanks, Asaf. -----Original Message----- From: Thomas Fischer [mailto:[EMAIL PROTECTED] Sent: Tuesday, October 18, 2005 09:23 To: Apache Torque Users List Subject: RE: Question regarding Criterias Hi, Sorry, this is not possible at the moment in a simple way. For joins, you would usually use Criteria.addJoin(), but at the moment, Torque only supports join clauses which are connected with an 'AND'. It might be possible to create your query using the methods Criteria.addSelectColumn() to add the colums of the joined table, and use the method described in http://db.apache.org/torque/releases/torque-3.2-rc2/runtime/peers-howto.html to create the or'd condition. Note: The DoSelectJoinYYY described in the same section will NOT help you, as they produce a simple join. Alternatively, you can also produce a double join using Criteria.addJoin() and join the field_connector table twice. This would imply using aliases (Criteria.addAlias) Thomas "Asaf Shakarchi" <[EMAIL PROTECTED]> schrieb am 17.10.2005 22:20:00: > 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. > > > > > > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
