Thanks Andreas and Greg . I knew about this features, but I was misleaded by the fact that adding to criteria in the other way wouldn't work even with an "or" operator.
I should have understood it anyway. Greg Monroe ha scritto: > For more information see the documentation at: > > http://db.apache.org/torque/releases/torque-3.3/runtime/reference/read-from-db.html#AND_and_OR_operators > > > >> -----Original Message----- >> From: Andras Balogh [mailto:and...@reea.net] >> Sent: Friday, May 08, 2009 5:52 AM >> To: Apache Torque Users List >> Subject: Re: multiple criteria on the same field >> >> Hi, >> >> You need to do something like: >> >> criteria.add( dataIscrizioneInizio.and(dataIscrizioneFine) ) ; >> >> to add both Criterions in the same time to the Criteria. >> >> Best regards, >> Andras >> >> >> Ivano Luberti wrote: >> >>> 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); >>> >>> >>> dataIscrizioneInizio.setIgnoreCase(true); >>> >>> criteria.add(dataIscrizioneInizio); >>> >>> Criterion dataIscrizioneFine = >>> criteria.getNewCriterion(IscrizioniSocioPeer.TABLE_NAME, "starttime", >>> (Date) (formUser.getDataIscrizioneFine()), Criteria.LESS_EQUAL); >>> >>> dataIscrizioneFine.setIgnoreCase(true); >>> >>> criteria.add(dataIscrizioneFine); >>> >>> 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); >>> sb.append(c.getTable()); >>> sb.append('.'); >>> sb.append(c.getColumn()); >>> 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 ? >>> >>> >>> >>> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: torque-user-unsubscr...@db.apache.org >> For additional commands, e-mail: torque-user-h...@db.apache.org >> >> > > DukeCE Privacy Statement: > Please be advised that this e-mail and any files transmitted with > it are confidential communication or may otherwise be privileged or > confidential and are intended solely for the individual or entity > to whom they are addressed. If you are not the intended recipient > you may not rely on the contents of this email or any attachments, > and we ask that you please not read, copy or retransmit this > communication, but reply to the sender and destroy the email, its > contents, and all copies thereof immediately. Any unauthorized > dissemination, distribution or copying of this communication is > strictly prohibited. > > --------------------------------------------------------------------- > To unsubscribe, e-mail: torque-user-unsubscr...@db.apache.org > For additional commands, e-mail: torque-user-h...@db.apache.org > > > -- ================================================== 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-unsubscr...@db.apache.org For additional commands, e-mail: torque-user-h...@db.apache.org