db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From T E Schmitz <mail...@numerixtechnology.de>
Subject Re: is this really the way to combine several or´s ?
Date Wed, 22 Dec 2004 22:58:24 GMT
Hello Alex,

Alex Hepp wrote:
> thanks all,
> but that can become a quite difficult thing, when i want to produce an 
> efficient and correct statement...
> is the following example statement possible with torque then? :

Yes, both examples are possible to configure with Torque. Just as you 
did it using Criterions.

> SELECT * FROM my_users where (LAST_NAME="Hepp" AND FIRST_NAME="Alex") or 
> LOGIN_NAME="heppa";

Criteria.Criterion a1 = crit.getNewCriterion( M.LAST_NAME,
                                 "Hepp", Criteria.EQUAL);
Criteria.Criterion a2 = crit.getNewCriterion( M.FIRST_NAME,
                                 "Alex", Criteria.EQUAL);
Criteria.Criterion a3 = crit.getNewCriterion( M.LOGIN_NAME,
                                 "heppa", Criteria.EQUAL);
Criteria.Criterion a4 = crit.getNewCriterion( M.USER_ID,
                                 "10023", Criteria.EQUAL);

> SELECT * FROM my_users where (LAST_NAME="Hepp" AND FIRST_NAME="Alex" or 
> LOGIN_NAME="heppa") or USER_ID="10023";

crit.add  a3.or(a4.or(a1.and(a2)));

I hope I got this right, if not shoot me down. But I'm sure you're 
getting the gist of it.

> well, i feel like you can only do this with a well configured debug 
> output;)

You just need to get your head round this and it will be quite simple. 
While coding, keep org.apache.torque.util.BasePeer at DEBUG level and 
you'll see the generated SQL. I have put some reasonably complicated 
stuff together and it works fine.
I often paste a longish generated SELECT into my editor, format it with 
some newlines and remove some columns, just to make it readable. I use 
UltraEdit with code colouring, which makes the SQL statements easier to 

Seasons Greetings,


To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org

View raw message