I think I find  a bug.
I used the torque 3.0.2.
when I used the second method ,but the result of query is wrong.
I open the log4j in debug mode.
I find the SQL query is wrong .
code:
   Criteria crit2 = new Criteria();
   crit2.add("BOOK.TITLE", (Object)"TCP", Criteria.LIKE);
   
   List results = BookPeer.doSelect(crit2);
   printBooklist(results);
The log4j is like this.
DEBUG [main] util.BasePeer (createQueryString:994) - SELECT book.BOOK_ID, book.TITLE, 
book.ISBN, book.TIME, book.PUBLISHER_ID, book.AUTHOR_ID FROM book, BOOK WHERE 
BOOK.TITLE = 'TCP'
DEBUG [main] util.BasePeer (executeQuery:1532) - Elapsed time=0 ms


----- Original Message ----- 
From: "Keeney, Thomas" <[EMAIL PROTECTED]>
To: "'Apache Torque Users List'" <[EMAIL PROTECTED]>
Sent: Thursday, July 31, 2003 12:50 AM
Subject: RE: How to do when i want to query like "select * from book where book.name 
like 'TCP' "?


Cast the second method parameter to an Object:
crit1.add(BookPeer.TITLE, (Object)"TCP", Criteria.LIKE);

The problem is that there is another Criteria.add() method that takes a
String as the second parameter, but this String represents the column name
and not its' value.  See the Criteria javadocs.

Best of luck!
Tom


-----Original Message-----
From: sailorhero [mailto:[EMAIL PROTECTED]
Sent: Wednesday, July 30, 2003 12:32 PM
To: Apache Torque Users List
Subject: Re: How to do when i want to query like "select * from book where
book.name like 'TCP' "?


I has used method which is like that you say.
but there is error in compileing this line when i work at eclipse.
code :
   Criteria crit1 = new Criteria();
   crit1.add(BookPeer.TITLE, "TCP", Criteria.LIKE);
   List results = BookPeer.doSelect(crit1);

java.lang.Error: 无法解析的编译问题:
 方法 add(String, Object, SqlEnum)对于类型 Criteria 有歧义

 at com.kazmier.BookStore.main(BookStore.java:76)
Exception in thread "main" 


----- Original Message ----- 
From: "Keeney, Thomas" <[EMAIL PROTECTED]>
To: "'Apache Torque Users List'" <[EMAIL PROTECTED]>
Sent: Wednesday, July 30, 2003 12:52 AM
Subject: RE: How to do when i want to query like "select * from book where
book.name like 'TCP' "?


> Try something like this,
> 
> Criteria crit = new Criteria();
> crit.add(bookPeer.NAME, 'TCP', Criteria.LIKE);
> List results = bookPeer.doSelect(crit);
> 
> Regards,
> Tom
> 
> -----Original Message-----
> From: sailorhero [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, July 29, 2003 10:23 AM
> To: [EMAIL PROTECTED]
> Subject: How to do when i want to query like "select * from book where
book.
> name like 'TCP' "?
> 
> 
> I used toruqe at Mssql database.
> I want to query something like this SQL :
> 
> select * from book where book.name like 'TCP' 
> 
> but how to use torque to query this?
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to