db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Aaron Loucks <aar...@GardnerInc.com>
Subject Force OR statement?
Date Mon, 10 Jan 2005 21:37:05 GMT
According to the API Docs :


or

public Criteria
<http://db.apache.org/torque/apidocs/org/apache/torque/util/Criteria.html>
or(java.lang.String column,
                   java.lang.Object value,
                   SqlEnum
<http://db.apache.org/torque/apidocs/org/apache/torque/util/SqlEnum.html>
comparison)

This method adds a new criterion to the list of criterias. If a criterion
for the requested column already exists, it is "OR"ed to the existing
criterion. If is used as follow:

 

Is there any way for force the Criteria to be OR'ed? For example I'm trying
to do something like the following:

 

 

SELECT * FROM table WHERE first_name LIKE '%queryString%' OR last_name LIKE
'%queryString%';

 

When I create the criteria by doing something like the following, it always
creates the statement with AND's rather than an OR. According to the
documentation this is correct, but this isn't the output I'm looking for. Is
there something in the API that I over looked? Or is this not possible?

 

Criteria c = new Criteria();

String queryString = "joe";

 

c.add(TablePeer.FIRST_NAME, (Object)("%" + queryString + "%"),
Criteria.LIKE);

c.or(TablePeer.LAST_NAME, (Object)("%" + queryString + "%"), Criteria.LIKE);

 

 

- Aaron

 


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