我有带保存方法的 DAO
public void save(BigDecimal cashBackAmount){
try (Connection connection = dataSource.getConnection();
PreparedStatement stmt = connection.prepareStatement(query)) {
stmt.setBigDecimal(1, cashBackAmount);
stmt.executeUpdate();
} catch (SQLException e) {
log.error(e.getMessage());
throw e;
}
}
}
findbug 说:
FindBugs: Unchecked/unconfirmed cast This cast is unchecked, and not all instances of the type casted from can be cast to the type it is being cast to. Check that your program logic ensures that this cast will not fa
如何设置BigDecimal?
stmt.setBigDecimal(1, new BigDecimal(????));
最佳答案
忽略警告/错误。在这种情况下,该消息完全没有意义。
很明显,您已经收到了BigDecimal
。因此您不可能收到其他对象。
关于java - 参数中的PreparedStatement setBigDecimal,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43225004/