db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Oliver Bethge" <oliver.bet...@gmx.de>
Subject Combining Criteria with other than AND
Date Mon, 28 Apr 2008 14:20:48 GMT
Hello,

I try to combine some Criteria with other operators than AND but it seems not possible to
me.

Here an example of the SQL I nerly want but it shows the main problems:

SELECT * FROM TABLE1 A, TABLE2 B WHERE A.KEY=B.KEY AND ((B.ORT='ORT1' AND B.PLZ IN (12345,12346))
OR (B.ORT='ORT2' AND B.PLZ IN (12347,12348)) AND NOT (B.OTHER='7' AND B.OTHER2=8)

Combinig Criteria with "AND NOT" looks impossible to me because of line 358ff in org.apache.torque.util.Query:

        if (!whereCriteria.isEmpty())
        {
            stmt.append(WHERE)
                .append(StringUtils.join(whereCriteria.iterator(), AND));
        }

So all Criteria will be connected by " AND ".

I tryed to use Criteria.CUSTOM but its also not possible to Connect them with " AND NOT ".

Sometimes it schould be possible to get an SQL like 

SELECT * FROM TABLE1 A, TABLE2 B WHERE A.KEY=B.KEY AND NOT (B.OTHER='7' AND B.OTHER2=8)

so it is not enougth to get some braces oround the whole WHERE-Clause.

Thanks,

 Oliver Bethge

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


Mime
View raw message