java - parameterized IN clause using multiple columns -


i have query along these lines, trying filter result set comparing tuples (like sql multiple columns in in clause):

select * mytable (key, value) in (values  ('key1', 'value1'),  ('key2', 'value2'),  ... ); 

this valid syntax , works fine on postgres 9.3 database.

i want invoke query through spring jdbc in value pairs come list<map<string,string>>.

it nice this:

list<map<string, string>> valuesmap = ...; string sql = "select * mytable (key, value) in (values :valuesmap)"; sqlparametersource params = new mapsqlparametersource("valuesmap", valuesmap); jdbctemplate.query(sql, params, rowmapper); 

when try this, get:

org.postgresql.util.psqlexception: no hstore extension installed.     @ org.postgresql.jdbc2.abstractjdbc2statement.setmap(abstractjdbc2statement.java:1707) ~[postgresql-9.3-1101-jdbc41.jar:na]     @ org.postgresql.jdbc2.abstractjdbc2statement.setobject(abstractjdbc2statement.java:1910) ~[postgresql-9.3-1101-jdbc41.jar:na]     @ org.postgresql.jdbc3g.abstractjdbc3gstatement.setobject(abstractjdbc3gstatement.java:36) ~[postgresql-9.3-1101-jdbc41.jar:na]     @ org.postgresql.jdbc4.abstractjdbc4statement.setobject(abstractjdbc4statement.java:47) ~[postgresql-9.3-1101-jdbc41.jar:na]     @ org.springframework.jdbc.core.statementcreatorutils.setvalue(statementcreatorutils.java:427) ~[spring-jdbc-4.2.3.release.jar:4.2.3.release]     @ org.springframework.jdbc.core.statementcreatorutils.setparametervalueinternal(statementcreatorutils.java:235) ~[spring-jdbc-4.2.3.release.jar:4.2.3.release]     @ org.springframework.jdbc.core.statementcreatorutils.setparametervalue(statementcreatorutils.java:150) ~[spring-jdbc-4.2.3.release.jar:4.2.3.release]     @ org.springframework.jdbc.core.preparedstatementcreatorfactory$preparedstatementcreatorimpl.setvalues(preparedstatementcreatorfactory.java:287) ~[spring-jdbc-4.2.3.release.jar:4.2.3.release]     @ org.springframework.jdbc.core.preparedstatementcreatorfactory$preparedstatementcreatorimpl.createpreparedstatement(preparedstatementcreatorfactory.java:244) ~[spring-jdbc-4.2.3.release.jar:4.2.3.release]     @ org.springframework.jdbc.core.jdbctemplate.execute(jdbctemplate.java:623) ~[spring-jdbc-4.2.3.release.jar:4.2.3.release] 

i've looked @ the hstore extension mentions. doesn't seem relevant problem.

is there way accomplish without dynamically building sql , parameter list?

all have pass list of arrays, each array contains key , value, this:

hashmap<string , string > map = new hashmap<>(); map.put("key0", "value0"); map.put("key1", "value1"); set<string> keys = map.keyset(); list<string[]> valuesmap = new arraylist<>(); for(string key:keys){     string[] entry = {key,map.get(key)};     valuesmap.add(entry); } string sql = "select * mytable (key, value) in (values :valuesmap)"; sqlparametersource params = new mapsqlparametersource("valuesmap", valuesmap); jdbctemplate.query(sql, params, rowmapper); 

this mentioned in spring documentation: http://docs.spring.io/spring-framework/docs/current/spring-framework-reference/html/jdbc.html#jdbc-in-clause


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -