How to link tuple list using Spring JDBCTemplate?

I have several such requests:

List listOfIntegers = Arrays.asList(new Integer[] {1, 2, 3});
List objects = 
    namedParameterJdbcTemplate.query("select * from bla where id in ( :ids )",
            Collections.singletonMap("ids", listOfIntegers),
            myRowMapper);

This will send this SQL query to the database:

select * from bla where id in ( 1, 2, 3 )

Now I want to send this type of request to the database:

select * from bla where (id,name) in ( (1,'foo'), (2,'bar'), (3,'foobar'))

Do I need to pass a list <List <Object →> for this? Will it work with Spring JDBCTemplate?

+4
source share
1 answer

I was debugging Spring code and found that it expects tuples to be provided as Object [], so to work with a list, it must be List <Object []>.

+8
source

Source: https://habr.com/ru/post/1538156/


All Articles