mybatis用法
2023-04-14 14:11 youxin 阅读(16) 评论(0) 编辑 收藏 举报//引用其它mapper.xml的sql片段 <include refid="namespace.sql片段"/>
<sql>用来封装SQL语句, <include>来调用,如果用了refid="base_column_list"则:
</select> <select id="selectOne" resultMap="BaseResultMap"> select <include refid="base_col_list"/> from entity_meta where id = #{entityId} </select> <sql id="base_col_list"> id, zh_name, en_name, color, parent_entity_id, is_sys_source, recent_backup_time, is_backup </sql>
sql片段
Sql中可将重复的sql提取出来,使用时用include引用即可,最终达到sql重用的目的,如下:
//建立sql片段 <sql id="query_user_where"> <if test="id!=null and id!=''"> and id=#{id} </if> <if test="username!=null and username!=''"> and username like '%${username}%' </if> </sql> //使用include引用sql片段 <select id="findUserList" parameterType="user" resultType="user"> select * from user <where> <include refid="query_user_where"/> </where> </select> //引用其它mapper.xml的sql片段 <include refid="namespace.sql片段"/>
https://www.cnblogs.com/sh086/p/8375791.html
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通
2018-04-14 gdb强制生成core文件
2018-04-14 c++类成员变量初始化相关问题
2016-04-14 php添加到桌面
2015-04-14 nginx php fastcgi安装
2012-04-14 hdc fibonacci number 1568
2012-04-14 多种方式求fibonacci数列
2012-04-14 杭电acm分类