在jdbctemplate中使用Postgres JSONB查询时出错

时间:2019-01-10 13:32:14

标签: jdbctemplate postgresql-9.5

PostgresSql查询

SELECT json_data FROM employee where json_data -> 'employee' @> '{"name":"Aman"}'

在postgres中运行时,此查询工作正常。但是,当使用jdbctemplate运行时,会引发错误。

Java代码

String sql="SELECT json_data FROM employee where json_data -> 'employee' @> '{\"name\":\"?\"}'";

List<Map<String, Object>> emp = jdbcTemplate.queryForList(sql,param);

在遇到代码的最后一行时,它会引发错误: 列索引超出范围:1,列数:0。嵌套的异常是org.postgresql.util.PSQLException。

它不能替代'?'占位符。

0 个答案:

没有答案