網站首頁 編程語言 正文
1.在查詢的時候對列名起別名
<mapper namespace="com.mingyu.mapper.UserMapper">
<select id="selectAll" resultType="com.mingyu.pojo.student">
select student_name as studentName,age from student
</select>
</mapper>
2.sql片段
在sql標簽中書寫sql語句,id屬性用來聲明該標簽的名字,在使用的時候將sql片段的名字寫在include標簽的refid的屬性中即可。
缺點:不夠靈活
<sql id="student_column">
student_name as studentName,age
</sql>
<select id="selectAll" resultType="com.mingyu.pojo.student">
select <include refid="student_column"></include>
from student
</select>
3.resultMap映射
通過使用resultMap映射來完成對指定關鍵字的映射。
select標簽中需要添加resultMap屬性才能完成映射。
<resultMap id="selectAllMap" type="com.mingyu.pojo.student">
<result column="student_name" property="studentName"></result>
</resultMap>
<select id="selectAll" resultMap="selectAllMap">
select *
from student
</select>
原文鏈接:https://blog.csdn.net/m0_72903413/article/details/140301004
- 上一篇:沒有了
- 下一篇:沒有了
相關推薦
- 2022-07-18 Uniapp中調整web-view的高度、獲取當前的web-view頁面URL
- 2022-08-01 Flutter移動端進行多渠道打包發布的全過程_Android
- 2022-07-25 Android?嵌套?Intent?隱患及解決方案_Android
- 2022-04-09 關于C語言動態內存管理介紹_C 語言
- 2022-09-04 C語言中反斜杠的作用及說明_C 語言
- 2023-01-26 Android入門之使用SQLite內嵌式數據庫詳解_Android
- 2022-04-08 go實現圖片拼接與文字書寫的方法實例_Golang
- 2021-12-07 Linux系統的修復模式(單用戶模式)_Linux
- 欄目分類
-
- 最近更新
-
- window11 系統安裝 yarn
- 超詳細win安裝深度學習環境2025年最新版(
- Linux 中運行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎操作-- 運算符,流程控制 Flo
- 1. Int 和Integer 的區別,Jav
- spring @retryable不生效的一種
- Spring Security之認證信息的處理
- Spring Security之認證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權
- redisson分布式鎖中waittime的設
- maven:解決release錯誤:Artif
- restTemplate使用總結
- Spring Security之安全異常處理
- MybatisPlus優雅實現加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務發現-Nac
- Spring Security之基于HttpR
- Redis 底層數據結構-簡單動態字符串(SD
- arthas操作spring被代理目標對象命令
- Spring中的單例模式應用詳解
- 聊聊消息隊列,發送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠程分支