db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alvaro Coronel <alvarocorone...@yahoo.com>
Subject RE: Problem with OR Clause
Date Fri, 11 May 2007 14:40:20 GMT
THX Greg. U are the definitive "answerer". That's why I seldom do it, and always start my mails
with the word "Maybe" :)

Best regards to everyone,
Álvaro.

Greg Monroe <Greg.Monroe@DukeCE.com> wrote: FWIW, using a criterion would also work,
but, IMHO, it's 
a little overkill for this.  You'd use a criterion here
if one or more of the fields where duplicated or you 
needed to do some special groupings.  E.g.:

  table.col1 = x or table.col1 = y 

Needs a criterion because col1 used twice.

  t.col1 = x and ( t.col2 >= y or t.col3 <= z)

Needs a criterion to get the or clause right.

The specified query had all different columns and
the logic didn't seem to need ordering.

But there are always a variety of ways to do things
and if it work, it isn't wrong. :D

> -----Original Message-----
> From: Alvaro Coronel [mailto:alvarocoronel67@yahoo.com] 
> Sent: Friday, May 11, 2007 9:52 AM
> To: Apache Torque Users List
> Subject: RE: Problem with OR Clause
> 
> Maybe you need to use a Criterion 
> 
> Criteria c = ;       
> Criteria.Criterion crit = c.getNewCriterion();
> c.or(crit);
> 
> Greg Monroe  wrote: Old version of 
> torque so I'm not sure about this.  But my
> best guess would be that the crit.add(...) / or(..) methods
> are returning a copy of the original criteria object rather 
> than the original criteria.
> 
> So, in your complex statement, the first and() gets applied
> to the original.  The subsequent or()s get applied to new
> (different) criteria objects.
> 
> Try adding an assignment to it.  E.g.:
> 
> crit = crit.and(...).or(...)...
> 
> > -----Original Message-----
> > From: Mark Wassermann [mailto:mwassermann@mw-net.com] 
> > Sent: Friday, May 11, 2007 3:29 AM
> > To: torque-user@db.apache.org
> > Subject: Problem with OR Clause
> > 
> > Hi List
> > 
> > Im using torque 3.1.1 as part of turbine 2.3.2.
> > 
> > I want to create a quere to find an expression in one of the 
> > text collums of a table. I tryed to use the Criteria.or 
> > method, but it dose not work right. The debug log shows that 
> > torque is gnerating the clause with AND instead of OR.
> > 
> > What did I do wrong?
> > 
> > thx4help
> > Mark
> > 
> > -- CODE --
> > crit.add(TicketPeer.LOCATION, project);
> > crit.add(TicketPeer.LAST_NAME, searchField).or(TicketPeer.VENDOR,
> > searchField).or(TicketPeer.MODEL, searchField);
> > -- CODE --
> > 
> > --LOG --
> > 2007-05-10 11:57:38,484 [http-8080-2] DEBUG 
> > org.apache.torque.util.BasePeer - SELECT TICKET.ID, 
> > TICKET.CUSTOMER_TYPE_ID, TICKET.CUSTOMER_NR, 
> > TICKET.FIRST_NAME, TICKET.LAST_NAME, TICKET.ADRESS, 
> > TICKET.ZIP, TICKET.CITY, TICKET.COUNTRY, TICKET.PHONE, 
> > TICKET.VEHICLE_TYPE_ID, TICKET.VENDOR, TICKET.MODEL, 
> > TICKET.CAR_NUMBER, TICKET.DESCRIPTION, TICKET.TRANSFER, 
> > TICKET.LOCATION, TICKET.CHECKIN_DATE, TICKET.CHECKIN_CLERK, 
> > TICKET.CHECKOUT_DATE, TICKET.CHECKOUT_CLERK, TICKET.RATE, 
> > TICKET.FREE_DAYS, TICKET.PRICE, TICKET.PAYED, TICKET.CLOSED 
> > FROM TICKET WHERE TICKET.LOCATION=1000 AND 
> > TICKET.LAST_NAME='Wassermann'
> > ORDER BY TICKET.CHECKIN_DATE ASC
> > LIMIT 20
> > --LOG --
> > 
> > -- Mark Wassermann @: mwassermann@mw-net.com
> > 
> > 
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> > For additional commands, e-mail: torque-user-help@db.apache.org
> > 
> > 
> 
> Duke CE 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
> 
> 
> 
>        
> ---------------------------------
> Park yourself in front of a world of choices in alternative vehicles.
> Visit the Yahoo! Auto Green Center.
> 

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



       
---------------------------------
Got a little couch potato? 
Check out fun summer activities for kids.
Mime
  • Unnamed multipart/alternative (inline, 8-Bit, 0 bytes)
View raw message