Welcome to the new Gigaspaces XAP forum. To recover your account, please follow these instructions.

Ask Your Question

SQLQuery with 'WHERE X IN ()'

Hi, I have this class: Class X { String name; }

I want to create this SQL query: ArrayList list = new ArrayList(); list.add("avi"); list.add("moshe"); SQLQuery query = new SQLQuery(X.class, "member IN (?)"); query.setParameters(list); space.readMultiple(query, null, Integer.MAX_VALUE);

But its not working, is there a way to set list parameters like this?

I want to do it because else way i will need to create a new SQLQuery each time i want to this query. and its too expensive.

any ideas how to do so?


{quote}This thread was imported from the previous forum. For your reference, the original is [available here|http://forum.openspaces.org/thread.jspa?threadID=2921]{quote}

asked 2009-03-03 12:55:00 -0500

sabag2's avatar

updated 2013-08-08 09:52:00 -0500

jaissefsfex's avatar
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

Try query.setParameters(array); Shay

answered 2009-03-03 13:52:06 -0500

shay hassidim's avatar
edit flag offensive delete link more


(Update) sorry, my code mistake :( , native array is ok. thanks Shay.

tried it and it didn't work. and im also familier with this thread - [//question/6136/sql-query-using-in/?comment=6138#comment-6138] but setParameters not working (List nor native array)

Edited by: Avi Laviad on Mar 4, 2009 9:51 AM - found a bug at my code.

sabag2's avatar sabag2  ( 2009-03-03 14:07:30 -0500 )edit

It's a well known fact that prepared statements and IN-clauses work very bad together. For your native array to work in this specific case you should use "... IN (?,?)", i.e. one ? for each item in the array. So the only way to re-use them are to keep one instance per array length ...

mirv's avatar mirv  ( 2009-03-05 09:04:42 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2009-03-03 12:55:00 -0500

Seen: 224 times

Last updated: Mar 03 '09