简单分页查询

注意,limit分页查询必须得是 int ,如果是字符串会报错.

  1. @Autowired
  2. private NamedParameterJdbcTemplate namedParameterJdbcTemplate;
  3. @Override
  4. public List<Map<String, Object>> queryNoneSolve(String limit) {
  5. if (StringUtils.isEmpty(limit)) {
  6. limit = "10";
  7. }
  8. String sql = "SELECT id, trace_id, " +
  9. "topic, tag, message_id, mq_body_content, trade_order_id, " +
  10. "reverse_order_id, is_solve, is_del, create_time, update_time, features, retry_reasons " +
  11. "FROM oms_order_mq_retry_upper_limit_log" +
  12. " WHERE is_del = 0 AND is_solve = 0 LIMIT :limit ";
  13. MapSqlParameterSource mapSqlParameterSource = new MapSqlParameterSource()
  14. // 添加参数
  15. .addValue("limit", Integer.valueOf(limit));
  16. List<Map<String, Object>> maps = namedParameterJdbcTemplate.queryForList(sql, mapSqlParameterSource);
  17. return maps;
  18. }