網站首頁 編程語言 正文
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
- 上一篇:沒有了
- 下一篇:沒有了
相關推薦
- 2024-01-09 bigdecimal保留兩位小數
- 2022-11-26 docker?prune命令定時清理不常用數據的操作方法_docker
- 2022-03-30 C語言關鍵字之auto?register詳解_C 語言
- 2022-10-15 QT?UDP網絡編程實現簡單消息傳輸_C 語言
- 2022-05-06 python使用xlrd模塊讀取excel的方法實例_python
- 2021-12-02 Android?Gson基本用法學習_Android
- 2022-08-16 .Net使用Xunit工具進行單元測試_實用技巧
- 2022-09-25 注解@Autowired如何自動裝配
- 欄目分類
-
- 最近更新
-
- 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同步修改后的遠程分支