blinkfox / fenix

This is an extension library to the Spring Data JPA complex or dynamic SQL query. 这是一个比 MyBatis 更加强大的 Spring Data JPA 扩展库,为解决复杂动态 JPQL (或 SQL) 而生。https://blinkfox.github.io/fenix
https://blinkfox.github.io/fenix
Apache License 2.0
345 stars 72 forks source link

查询结果问题 。 #6

Closed wusyJava closed 4 years ago

wusyJava commented 4 years ago

sql为: SELECT user_id as id, user_name as name, account as account,companyname as companyName,grouppath as groupPath FROM user java为: @QueryFenix(value = "SysUserDao.queryForRoleSelList", nativeQuery = true) List<Map<String, Object>> queryForRoleSelList(SysUserParams params, Set orders);

如何让Map 中的key 为id 而不是ID

blinkfox commented 4 years ago

用原生 SQL 这样写,JPA 会默认转成大写的。虽然是大写的,不过你也可以用小写去 get 里面的元素也是可以得到数据的。

如果非要转成小写的话,你得用 JPQL 语句去写,以 new map 返回就是小写的了,示例如:

SELECT new map(userId as id, userName as name, account as account, companyName as companyName,groupPath as groupPath) FROM User
wusyJava commented 4 years ago

好的,谢谢!

wushanying@foxmail.com

发件人: 闪烁之狐 (blinkfox) 发送时间: 2019-12-10 00:08 收件人: blinkfox/fenix 抄送: wusyJava; Author 主题: Re: [blinkfox/fenix] 查询结果问题 。 (#6) 用原生 SQL 这样写,JPA 会默认转成大写的。虽然是大写的,不过你也可以用小写去 get 里面的元素也是可以得到数据的。 如果非要转成小写的话,你得用 JPQL 语句去写,以 new map 返回就是小写的了,示例如: SELECT new map(userId as id, userName as name, account as account, companyName as companyName,groupPath as groupPath) FROM User — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.