mybatis中select语句字段大小写问题

我用的mybatis3.0.5

如果你用的mybatis3.0.5的话就会存在这个问题(其他版本我不知道),我以解决,改版后的mybatis-3.0.5.jar提供下载,替换项目中就好!

//org.apache.ibatis.executor.resultset.FastResultSetHandler中第298行代码,
mybatis3.0.5源代码为:

protected void loadMappedAndUnmappedColumnNames(ResultSet rs, ResultMap resultMap, List mappedColumnNames, List unmappedColumnNames) throws SQLException {
    mappedColumnNames.clear();
    unmappedColumnNames.clear();
    final ResultSetMetaData rsmd = rs.getMetaData();
    final int columnCount = rsmd.getColumnCount();
    final Set mappedColumns = resultMap.getMappedColumns();
    for (int i = 1; i <= columnCount; i++) {
      final String columnName = configuration.isUseColumnLabel() ? rsmd.getColumnLabel(i) : rsmd.getColumnName(i);
      final String upperColumnName = columnName.toUpperCase(Locale.ENGLISH);
      if (mappedColumns.contains(upperColumnName)) {
        mappedColumnNames.add(upperColumnName);
        mappedColumnNames.add(columnName);
      } else {
        unmappedColumnNames.add(upperColumnName);
        unmappedColumnNames.add(columnName);
      }
    }
  }

修改后的代码为:

protected void loadMappedAndUnmappedColumnNames(ResultSet rs, ResultMap resultMap, List mappedColumnNames, List unmappedColumnNames) throws SQLException {
    mappedColumnNames.clear();
    unmappedColumnNames.clear();
    final ResultSetMetaData rsmd = rs.getMetaData();
    final int columnCount = rsmd.getColumnCount();
    final Set mappedColumns = resultMap.getMappedColumns();
    for (int i = 1; i <= columnCount; i++) {
      final String columnName = configuration.isUseColumnLabel() ? rsmd.getColumnLabel(i) : rsmd.getColumnName(i);
      //final String upperColumnName = columnName.toUpperCase(Locale.ENGLISH);
      if (mappedColumns.contains(upperColumnName)) {
        //mappedColumnNames.add(upperColumnName);
        mappedColumnNames.add(columnName);
      } else {
        //unmappedColumnNames.add(upperColumnName);
        unmappedColumnNames.add(columnName);
      }
    }
  }

 提供编译好的jar替换就可以 下载地址:http://pan.baidu.com/s/1pJyqavh

 

转载于:https://my.oschina.net/Thinkeryjgfn/blog/373771

你可能感兴趣的:(mybatis中select语句字段大小写问题)