mybatis返回类型map时key大写转为小写方法

亲测:
SELECT DEPTNO as "deptno",DEPTNAME,DEPTGRADE,PARENTDEPT 
      FROM VMGR_DEPT
      ORDER BY DEPTGRADE,DEPTNO

别人案例:

  <select id="selectBlogRetHashMap" parameterType="int" resultType="map">  
        SELECT id AS "id", title AS "title", content AS "content" FROM Blog WHERE id = #{id}  
    </select> 

纯java实现方法(推荐):

public class Snippet {
	public static Map<String, Object> transformUpperCase(Map<String, Object> orgMap) {
		Map<String, Object> resultMap = new HashMap<>();

		if (orgMap == null || orgMap.isEmpty()) {
			return resultMap;
		}

		Set<String> keySet = orgMap.keySet();
		for (String key : keySet) {
			String newKey = key.toLowerCase();
			newKey = newKey.replace("_", "");

			resultMap.put(newKey, orgMap.get(key));
		}

		return resultMap;
	}
}

猜你喜欢

转载自blog.csdn.net/qq_36421955/article/details/80847018