为什么升级mySql后getJdbcTemplate()。query返回空列表?

时间:2018-12-11 09:42:11

标签: java mysql spring jdbctemplate

我最近从Java 6升级到8,将mySql 5.5升级到5.7,将Spring MVC 2升级到5.0.9。我有以下代码,这些代码在升级之前可以工作。但是现在,如果我尝试返回带有一个条目的Map列表,但是Map为空。但事实是,数据库只有一个可用值。

Map<Integer, String> transmittalIds =  new HashMap<Integer, String>();    
String query = "";
    query.append("SELECT TRANSMITTALID, TRANSMITTALCODE FROM LEADERTRANSMITTAL WHERE ")
            .append(" CASENUMBERREPORT = 'N'")
            .append(" AND STATUS = 'SENT'");

    List<Map<Integer, String>> list = getJdbcTemplate().query(query.toString(), new TransmittalIdMapper()); 

    public static final class TransmittalIdMapper implements RowMapper<Map<Integer, String>>{

            @Override
            public Map<Integer, String> mapRow(ResultSet rs, int arg1) throws SQLException {

                Map<Integer, String> map = new HashMap<Integer, String>();

                while(rs.next()){
                    int transmittalId = rs.getInt("TRANSMITTALID");
                    String transmittalCode = rs.getString("TRANSMITTALCODE");

                    map.put(transmittalId, transmittalCode);
                }
                return map;
            }
        }

        System.out.println("List size: "+list.size());

          if( list != null && !list.isEmpty()){
              System.out.println("List: "+list.get(0));
              System.out.println("Map: "+list.get(0).size());
              transmittalIds = list.get(0);
          }

以下内容输出: 列表大小:1 列表:{} 地图:0

0 个答案:

没有答案