mybatis注解版in查询、字符串判空模糊匹配 、批量插入、插入返回主键
IN查询
@Select({"<script> " +
" select * "+
" from business_threat bt \n" +
" join abnormal_event_type aet on bt.event_type_id = aet.id " +
" where 1=1 " +
" <if test = ' ids != null'> " +
" and bt.id in " +
" <foreach item = 'item' index = 'index' collection = 'ids' open = '(' separator = ',' close = ')' > " +
" #{item} " +
" </foreach> " +
" </if> " +
"</script>"})
List<BusinessThreatVO> getByBusinessThreadId(@Param("ids") List<Long> ids);
模糊查询 ' '这个就是 表示不等于空字符串
"<if test='userName !=null and userName!= '' ' >" +
" and u.user_name like CONCAT('%',#{userName},'%') " +
" </if>" +
批量插入
@Insert({
"<script>",
"insert into table_name(column1, column2) values ",
"<foreach collection='lists' item='item' index='index' separator=','>",
"(#{item.实体属性1}, #{item.实体属性2})",
"</foreach>",
"</script>"
})
int insertCollectList(@Param(value="lists") List<Test> lists);
插入数据返回主键
@Options(useGeneratedKeys = true,keyProperty ="id(主键的字段)")
@Insert(" insert into user (id, user_name, ”)
mybatis注解版in查询、字符串判空模糊匹配 、批量插入、插入返回主键的更多相关文章
- Java MyBatis 插入数据库返回主键--insertSelective这样就不用每次到数据库里面查询了
insertSelective---Java MyBatis 插入数据库返回主键--insertSelective这样就不用每次到数据库里面查询了 https://www.cnblogs.com/xi ...
- Java MyBatis 插入数据库返回主键
最近在搞一个电商系统中由于业务需求,需要在插入一条产品信息后返回产品Id,刚开始遇到一些坑,这里做下笔记,以防今后忘记. 类似下面这段代码一样获取插入后的主键 User user = new User ...
- MyBatis 插入数据库返回主键
最近在搞一个电商系统中由于业务需求,需要在插入一条产品信息后返回产品Id,刚开始遇到一些坑,这里做下笔记,以防今后忘记. 类似下面这段代码一样获取插入后的主键 User user = new User ...
- MyBatis框架——mybatis插入数据返回主键(mysql、oracle)
向数据库中插入数据时,大多数情况都会使用自增列或者UUID做为主键.主键的值都是插入之前无法知道的,但很多情况下我们在插入数据后需要使用刚刚插入数据的主键,比如向两张关联表A.B中插入数据(A的主键是 ...
- MyBatis插入语句返回主键值
插入语句xml代码: <insert id="insertUser" parameterType="com.spring.mybatis.po.User" ...
- mybatis与mysql插入时返回主键id的值
<insert id="insertCharge" parameterType="com.bb.bean.Rechargerecord"> < ...
- MyBatis中插入并返回主键
开发过程中经常遇到需要插入一条数据,并且返回这条数据自增的主键,在MyBatis中只需要在mapper中添加keyProperty属性即可 在mapper中添加keyProperty属性 <in ...
- mybatis插入是返回主键id
<!-- 插入数据:返回记录的id值 --> <insert id="insertOneTest" parameterType="org.chench. ...
- 关于mybatis插入数据库返回主键id
关于Sequence主键的数据库来说,如: <insert id="add" parameterType="vo.Category"> <se ...
随机推荐
- 金蝶EAS——登录某个数据中心门户时报错“获取用户相关信息失败!请查看服务器日志,并确认是否数据库设置错误或者版本不匹配!”
登录服务器后台,查看金蝶BOS控制台,选择数据中心中的目标数据中心,点击测试连接,提示报错如下: 说明是数据库问题,需要登录数据库服务器去检查数据库.详细操作见:
- 嵌入式Linux利用ppp实现4G模块联网
https://blog.csdn.net/qq361294382/article/details/52136126 https://blog.csdn.net/qq361294382/article ...
- MPI 学习笔记
目录 MPI学习笔记 MPI准备 概述 前置知识补充 环境部署 1.修改IP及主机名 2.关闭防火墙 3.实现免密码SSH登录 4.配置MPI运行环境 5.测试 程序的执行 编译语句 运行语句 MPI ...
- 理解ASP.NET Core - 模型绑定&验证(Model Binding and Validation)
注:本文隶属于<理解ASP.NET Core>系列文章,请查看置顶博客或点击此处查看全文目录 模型绑定 什么是模型绑定?简单说就是将HTTP请求参数绑定到程序方法入参上,该变量可以是简单类 ...
- A Child's History of England.10
In the next reign, which was the reign of Edward, surnamed The Elder, who was chosen in council to s ...
- 26. Linux GIT
windows git 下载链接: Msysgit https://git-scm.com/download/win 1 进入git bash进行第一次配置 git config --global ...
- Leetcode中的SQL题目练习(一)
595. Big Countries https://leetcode.com/problems/big-countries/description/ Description name contine ...
- Output of C++ Program | Set 2
Predict the output of below C++ programs. Question 1 1 #include<iostream> 2 using namespace st ...
- Linux基础命令---vmstat显示虚拟内存状态
vmstat vmstat指令用来显示虚拟内存使用状态,同时也可以显示进程.cpu活动情况.vmstat报告有关进程.内存.分页.块IO.陷阱和CPU活动的信息.生成的第一份报告给出了自上次重新启动以 ...
- 找出1小时内占用cpu最多的10个进程的shell脚本
cpu时间是一项重要的资源,有时,我们需要跟踪某个时间内占用cpu周期最多的进程.在普通的桌面系统或膝上系统中,cpu处于高负荷状态也许不会引发什么问题.但对于需要处理大量请求的服务器来讲,cpu是极 ...