How to query for an postgres integer array in spring

Viewed 5450

I am using Java 7 and JDBC template to query a integer array from PostgreSQL. My code is as below:

@Autowired
private JdbcTemplate jdbcTemp;

String SQL = "select item_list from public.items where item_id=1";
List<Integer> ListOfitems=jdbcTemp.queryForList(SQL , Integer.class);

My item_list column is integer[] in PostgreSQL. But when I try like this it throws an error as:

Bad value for type int psql exception

I also tried:

List<List<Integer>> ListOfitems=jdbcTemp.queryForList(SQL , Integer.class);

But it still throws the same exception.

Any help is appreciated.

3 Answers
Related