db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ivano Luberti <lube...@archicoop.it>
Subject multiple criteria on the same field
Date Fri, 08 May 2009 07:43:55 GMT
Hello , I have searched the ml and googled for this.
I have found 2 old email asking for this but with no answer.

When I try to do this :

Criteria criteria = new Criteria();
Criterion dataIscrizioneInizio =
criteria.getNewCriterion(IscrizioniSocioPeer.TABLE_NAME, "starttime", 
(Date) (formUser.getDataIscrizioneInizio()), Criteria.GREATER_EQUAL);   



Criterion dataIscrizioneFine =
criteria.getNewCriterion(IscrizioniSocioPeer.TABLE_NAME, "starttime", 
(Date) (formUser.getDataIscrizioneFine()), Criteria.LESS_EQUAL);           



Only the last criterion is included in the where clause.

I have stepped into the add(Criterion) method of the Criteria class and
found this:

    public Criteria add(Criterion c)
        StringBuffer sb = new StringBuffer(c.getTable().length()
                + c.getColumn().length() + 1);
        super.put(sb.toString(), c);
        return this;

If I understand well , the map keys are based on the table and field
names then it is not possible to add two criteria on the same field to
produce sql like:

SELECT * FROM table WHERE table.field>x AND table.field<y

Can someone suggest the best practice to do this with Torque ?

dott. Ivano Mario Luberti
Archimede Informatica societa' cooperativa a r. l.
Sede Operativa
Via Gereschi 36 - 56126- Pisa
tel.: +39-050- 580959
tel/fax: +39-050-9711344
web: www.archicoop.it

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

View raw message