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); crit.add(a3.or(a1.and(a2)));
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 read.
--
Seasons Greetings,
Tarlika
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
