db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Greg Monroe <Greg.Mon...@dukece.com>
Subject RE: multiple criteria on the same field
Date Fri, 08 May 2009 12:57:41 GMT
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:andras@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-unsubscribe@db.apache.org
> For additional commands, e-mail: torque-user-help@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-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org


Mime
View raw message