我需要将 BigInteger 参数传递给 SQL 查询。(在 Postgres 9.2 上)我的 DAO 中有以下代码:
public List<PersonInfo> select(String id) {
BigInteger bigIntId = new BigInteger(id);
JdbcTemplate select = new JdbcTemplate(dataSource);
return select
.query("SELECT * FROM PE.SUPPLIER_INPUT_DATA WHERE ID = ?",
new Object[] { bigIntId },
new PersonRowMapper());
}
我收到以下异常:
{"error":"Error invoking getPersonInfoById.[org.springframework.jdbc.BadSqlGrammarException: PreparedStatementCallback;
bad SQL grammar [SELECT * FROM PE.SUPPLIER_INPUT_DATA WHERE ID = ?];
nested exception is org.postgresql.util.PSQLException:
Can't infer the SQL type to use for an instance of java.math.BigInteger.
Use setObject() with an explicit Types value to specify the type to use.]"}
id 的类型为 bigint
试图传递纯字符串 - 也会引发类型异常。谷歌搜索异常中的消息 - 没有相关结果。有任何想法吗?