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:[EMAIL PROTECTED] > 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 @: [EMAIL PROTECTED] > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > 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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]