How can I execute somethings like this in jDBI ?
@SqlQuery(\"select id from foo where name in \")
List getIds(@Bind(
If you are using the JDBI 3 Fluent API, you can use bindList() with an attribute:
List keys = new ArrayList()
keys.add("user_name");
keys.add("street");
handle.createQuery("SELECT value FROM items WHERE kind in ()")
.bindList("listOfKinds", keys)
.mapTo(String.class)
.list();
// Or, using the 'vararg' definition
handle.createQuery("SELECT value FROM items WHERE kind in ()")
.bindList("varargListOfKinds", "user_name", "docs", "street", "library")
.mapTo(String.class)
.list();
Note how the query string uses instead of the usual :listOfKinds.
Documentation is here: http://jdbi.org/#_binding_arguments