这篇文章主要讲解了“mybatis返回类型map时怎么把key大写转为小写”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“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>
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; } }
在查询的字段后加别名
user_id as “userId”
注意:别名必须加双引号
<select id="queryMaxPriceAAndUser" parameterType="java.lang.String" resultType="java.util.HashMap"> SELECT A.SELL_PRICE as "price", B.USER_ID as "userId" FROM QLYY_SELL_AUCTION_RECORD A, QLYY_SELL_APPLY B WHERE A.SELL_PRICE = (SELECT MAX(SELL_PRICE) FROM QLYY_SELL_AUCTION_RECORD WHERE SELL_PROGRAM_ID = #{programId}) AND A.SELL_PROGRAM_ID = #{programId} AND B.APPLY_CODE = A.SELL_USER </select>
感谢各位的阅读,以上就是“mybatis返回类型map时怎么把key大写转为小写”的内容了,经过本文的学习后,相信大家对mybatis返回类型map时怎么把key大写转为小写这一问题有了更深刻的体会,具体使用情况还需要大家实践验证。这里是亿速云,小编将为大家推送更多相关知识点的文章,欢迎关注!
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。