批量操作

/*** 批量删除/启用 禁用 (更新操作)** @param examExt* @return*/
int batchOperationWithUpdate(ExamExt examExt);// 批量处理【启用/禁用/删除】
List <Integer> examIds;<!-- 批量删除 / 启用 / 禁用 -->
<update id="batchOperationWithUpdate">UPDATE exam<set><if test="delId!=null">del_id = #{delId},</if></set>WHERE exam_id IN<foreach collection="examIds" item="item" separator="," open="(" close=")">#{item}</foreach>
</update>

<resultMap>来映射字段名和实体类属性名


<select id="getOrder" parameterType="int" resultMap="orderresultmap">select * from orders where order_id=#{id}
</select><resultMap type=”me.gacl.domain.order” id=”orderresultmap”><!–用id属性来映射主键字段–><id property=”id” column=”order_id”><!–用result属性来映射非主键字段,property为实体类属性名,column为数据表中的属性–><result property = “orderno” column =”order_no”/><result property=”price” column=”order_price” />
</reslutMap>

自动生成的(主)键值

<insert id=”insertname” usegeneratedkeys=”true” keyproperty=”id”>insert into names (name) values (#{name})
</insert>

在mapper中如何传递多个参数

方法一:// DAO层的函数
Public UserselectUser(String name,String area);<select id="selectUser"resultMap="BaseResultMap">  select *  fromuser_user_t whereuser_name = #{0} anduser_area=#{1}
</select>
方法二:user selectuser(@param(“username”) string username,@param(“hashedpassword”) string hashedpassword); <select id=”selectuser” resulttype=”user”>select id, username, hashedpassword from some_table where username = #{username} and hashedpassword = #{hashedpassword}
</select>

mybatis xml sql相关推荐

  1. mybatis.xml中sql编写规范

    一.越少的代码,越强悍的功能,xml里面应该6个sql语句就够用了,修改,维护成本很低,见下表 下载 英文名 方法名称 核心点 建议 insert 1.新增数据 如果是自增主键,应该返回主键ID de ...

  2. Mybatis.xml中sql语句的转译

    Mybatis.xml中sql语句的转译

  3. MyBatis动态SQL之 set 和 trim标记的使用示例

    2019独角兽企业重金招聘Python工程师标准>>> 和之前的where一样,set和trim也是智能标记 在之前的user.xml中添加 <update id=" ...

  4. 9.mybatis动态SQL标签的用法

    mybatis动态SQL标签的用法 动态 SQL MyBatis 的强大特性之一便是它的动态 SQL.如果你有使用 JDBC 或其他类似框架的经验,你就能体会到根据不同条件拼接 SQL 语句有多么痛苦 ...

  5. MyBatis-06 MyBatis XML方式之多个接口参数用法

    概述 模拟场景:根据用户ID和角色的enable状态来查询用户的所有角色 工程结构 多个基本类型参数的场景 1.UserRoleMapper接口增加接口方法 2.UserRoleMapper.xml配 ...

  6. MyBatis-04 MyBatis XML方式之insert元素

    insert概述 简单的insert用法 1. UserMapper中添加接口方法 2. UserMapper.xml 添加节点 3. 编写单元测试 使用JDCB方式返回主键自增的值 1.UserMa ...

  7. MyBatis-03 MyBatis XML方式之select元素

    概述 select用法 根据用户id查询用户信息 1.UserMapper接口中添加接口方法 2. UserMapper.xml中配置resultMap和select元素 查询全部的SysUser 添 ...

  8. MyBatis-02 MyBatis XML方式概述及配置步骤

    概述 一个简单的权限控制需求 创建数据库表 创建实体类 XML方式概述及步骤 1. 首先在src/main/resources下com.artisan.mybatis.xml.mapper目录下创建5 ...

  9. MyBatis动态SQL底层原理分析

    前言 废话不多说,直接进入文章. 我们在使用mybatis的时候,会在xml中编写sql语句. 比如这段动态sql代码: <update id="update" parame ...

最新文章

  1. 被公司圈养的年轻人,如何避免被市场淘汰?
  2. 基于托管C++的增删改查及异步回调小程序
  3. mongodb windows安装
  4. input函数的基本使用
  5. 《MySQL实战45讲》基础理论篇 1-8讲 学习笔记
  6. STM32 CAN过滤器
  7. memcache_engine + memcachedb = 高性能分布式内存数据库
  8. delphi学习路线
  9. 总结下MySql优化。防止数据灾难的发生。
  10. position之属性
  11. 修改页面后获得flag_逆向基础题五:获取Flag
  12. 在搭建tesseract-OCR环境中遇到问题和反省
  13. 刷好老毛子系统进不了老毛子系统后台的解决办法
  14. mysql 统计每天、每周、每月、每年数据
  15. Html5 css3 导航箭头,HTML – CSS3导航箭头
  16. iOS主题/皮肤之SakuraKit
  17. 无线连接steam网络连接服务器,教你无法连接到steam网络 完美解决方法
  18. 希腊字母书写以及发音,常用场景
  19. 百度easydl数据标注
  20. python break函数用法_Python break用法详解

热门文章

  1. LD-sketch源码阅读
  2. Appium之开发计算器自动化测试脚本Demo
  3. 【转载】计算几何题目集锦
  4. C#为null或Empty
  5. 微信公众平台开发4-长链接转短链接口调用实例(含源码)
  6. 解决log4j:WARN Error initializing output writer. log4j:WARN Unsupported encoding?的问题
  7. Android SDK Manager无法显示可供下载的未安装SDK解决方案
  8. 如何自定义一个异常类
  9. 【干货】数字化运营:从理论到实践.pdf(附下载链接)
  10. 【报告分享】2020年抖音美妆直播报告.pdf(附下载链接)