zhangjingl02 / activejdbc

Automatically exported from code.google.com/p/activejdbc
0 stars 0 forks source link

sql statement "in" doesn't work #185

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. create an ArrayList of id's as integers ("idList"); create a table with id 
(named it "categories"
2. run this line: LazyList<Category> mapped = Category.where("id in ?", idList);
3. Exception reached

org.javalite.activejdbc.DBException: 
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in 
your SQL syntax; check the manual that corresponds to your MySQL server version 
for the right syntax to use near 
'_binary'¬í\0sr\0java.util.LinkedList)S]J`ˆ\"\0\0xpw\0\0\0sr\0j
ava.lang' at line 1, Query: SELECT  * FROM categories WHERE  id in ?, params: 
[1703, 1704, 1705]
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:532)

What is the expected output? What do you see instead?
- Expecting to get the rows associated with the id's

What version of the product are you using? On what operating system?
- 1.4.5

Please provide any additional information below.
- tried with .where() and .find() methods - neither works.
- tried with array, list, string as input (ex: idList = "(1703, 1704, 1705)"); 
neither works.

Original issue reported on code.google.com by yzh...@onescreen.com on 19 Dec 2012 at 6:20

GoogleCodeExporter commented 9 years ago
will not fix this because not supported in JDBC. 

Please, see this discussion for a workaround:
https://groups.google.com/forum/?fromgroups=#!searchin/activejdbc-group/javagirl
/activejdbc-group/ZbzW1GRPX5Q/IpU8t3mOPo0J

Original comment by i...@polevoy.org on 19 Dec 2012 at 8:15