Jdbi - how to bind a list parameter in Java?

后端 未结 2 745
独厮守ぢ
独厮守ぢ 2020-12-10 03:00

We have an SQL statement which is executed by Jdbi (org.skife.jdbi.v2). For binding parameters we use Jdbi\'s bind method:

Handle h         


        
2条回答
  •  星月不相逢
    2020-12-10 03:33

    The article you linked also descibes the @BindIn annotation. This provides a general purpose implementiation for lists.

    @UseStringTemplate3StatementLocator
    public class MyQuery {
      @SqlQuery("select id from foo where name in ()")
      List getIds(@BindIn("nameList") List nameList);
    }
    

    Please note that you'll have to escape all pointy brackets < like this \\<. There is a previous discusion on SO: How to do in-query in jDBI?

提交回复
热议问题