In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains the "MybatisPlus page sorting query field with underlined solution is", the article explains the content is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in-depth, together to study and learn "MybatisPlus page sorting query field with underlined solution is what" it!
MybatisPlus pagination sort query field with underscore
If you use MybatisPlus's automatic hump naming, there will be a problem when the fields of the paging sort query are underlined.
Page = new Page (pageNo, pageSize); OrderItem orderItem = new OrderItem (); orderItem.setColumn ("create_date"); orderItem.setAsc (isAsc); page.addOrder (orderItem); return page
If the paging object is encapsulated in this way, and the field is create_date, the field of order by will automatically become createDate when it is finally executed.
But the database is underlined, so the field can not be found. If it is changed to createDate, he still sorts it by createDate, which cannot be solved. I don't know if you've ever encountered this hole.
Finally, I changed the database field to createdate.
The MybatisPlus field name is underlined and queried as null
When writing sql query in Mybatis-plus, resultType is used to do field mapping, and the value of underlined field can not be queried.
Cause Analysis of SELECT temp.* FROM (SELECT. * from w_xkxmsjlxr t INNER JOIN w_xkxmjbxx wx ON t.SSXKXMJBXX_ID = wx.ID AND wx.SCBJ = 0 and t.scbj = 0 INNER JOIN s_xzqh sx ON sx.QHDM = # {qhdm} and wx.XZQHDM like CONCAT ('%', sx.XJQHDMBDS,'%')) as temp ${ew.customSqlSegment}
Mybatis-plus enables hump conversion by default, and the ssxkxmjbxx_id field is converted to ssxkxmjbxxId, which cannot be queried naturally.
Solution
(1) turn off Mybatis-plus hump conversion, which can solve the problem, but it will affect the whole project and the loss outweighs the gain.
(2) use resultMap to do mapping and write the mapping relationship by yourself.
SELECT temp.* FROM (SELECT. * from w_xkxmsjlxr t INNER JOIN w_xkxmjbxx wx ON t.SSXKXMJBXX_ID = wx.ID AND wx.SCBJ = 0 and t.SCBJ = 0 INNER JOIN s_xzqh sx ON sx.QHDM = # {qhdm} and wx.XZQHDM like CONCAT ('%', sx.XJQHDMBDS,'%')) as temp ${ew.customSqlSegment}
Ps: use Mybaits-plus code generator to avoid the trouble of writing tedious mapping!
Thank you for your reading, the above is the "MybatisPlus page sorting query field with underlined solution is what" the content, after the study of this article, I believe you on the MybatisPlus page sorting query field with underlined solution is what this problem has a deeper understanding, the specific use of the need for you to practice and verify. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.