Mybatis常用标签使用
trim元素的主要功能是可以在自己包含的内容前加上某些前缀,也可以在其后加上某些后缀,与之对应的属性是prefix和suffix;可以把包含内容的首部某些内容覆盖,即忽略,也可以把尾部的某些内容覆盖,对应的属性是prefixOverrides和suffixOverrides;
<insert id="operatorLog" parameterType="com.oa.model.wxlog.WxLog">
INSERT INTO sdb_oa_operator_log
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="open_id!='' and open_id != null">
open_id,
</if>
<if test="operatortime!='' and operatortime != null">
operatortime,
</if>
<if test="operatortype!='' and operatortype != null">
operatortype,
</if>
<if test="operatorcont!='' and operatorcont != null">
operatorcont,
</if>
<if test="ip!='' and ip != null">
ip,
</if>
</trim>
<trim prefix="values(" suffix=")" suffixOverrides="," >
<if test="open_id!='' and open_id != null">
#{open_id},
</if>
<if test="operatortime!='' and operatortime != null">
#{operatortime},
</if>
<if test="operatortype!='' and operatortype != null">
#{operatortype},
</if>
<if test="operatorcont!='' and operatorcont != null">
#{operatorcont},
</if>
<if test="ip!='' and ip != null">
#{ip},
</if>
</trim>
</insert>
Mybatis 配置文件 useGeneratedKeys 参数只针对 insert 语句生效,默认为 false。
当设置为 true 时,表示如果插入的表以自增列为主键,则允许 JDBC 支持自动生成主键,并可将自动生成的主键返回。
<insert id="saveMain" parameterType="java.util.HashMap" keyProperty="id" useGeneratedKeys="true">
insert into <include refid="tableName"></include>(
<include refid="Field"></include>
) values (
<include refid="FieldValue"></include>
)
</insert>
--------------Mybatis 拼接like ---
and date_format(company.create_time,'%Y-%m-%d %H:%i:%s') LIKE CONCAT('%', '${params.create_time}', '%')
----------------mybatis 判断参数要加.toString()---
<if test="params.selectTime =='2'.toString() ">
Mybatis常用标签使用的更多相关文章
- MyBatis - 常用标签与动态Sql
MyBatis常用标签 ● 定义sql语句:select.insert.delete.update ● 配置JAVA对象属性与查询结构及中列明对应的关系:resultMap ● 控制动态sql拼接:i ...
- Mybatis 常用标签
MyBatis 的强大特性之一便是它的动态 SQL.如果你有使用 JDBC 或其他类似框架的经验,你就能体会到根据不同条件拼接 SQL 语句有多么痛苦.拼接的时候要确保不能忘了必要的空格,还要注意省掉 ...
- [Mybatis]Mybatis 常用标签及功能整理
Mybatis中生成动态SQL的标签有四类,分别是: if choose (when, otherwise) trim (where, set) foreach 1.if 当需要动态生成where条件 ...
- mybatis常用标签
1. 定义sql语句 1.1 select 标签 属性介绍: id :唯一的标识符. parameterType:传给此语句的参数的全路径名或别名 例:com.test.poso.User或user ...
- mybatis常用标签(转)
1. 定义sql语句 select 标签 属性介绍: id :唯一的标识符. parameterType:传给此语句的参数的全路径名或别名 例:com.test.poso.User或user resu ...
- [刘阳Java]_MyBatis_映射文件的常用标签总结_第5讲
MyBatis中常用标签的总结,简单给出自己的总结 MyBatis映射文件中的标签使用介绍1.<select>:用于编写查询语句用的标签 id:表示当前<select>标签的唯 ...
- Mybatis 常用注解
Mybatis常用注解对应的目标和标签如表所示: 注解 目标 对应的XML标签 @CacheNamespace 类 <cache> @CacheNamespaceRef 类 <cac ...
- Mybatis foreach标签含义
背景 考虑以下场景: InfoTable(信息表): Name Gender Age Score 张三 男 21 90 李四 女 20 87 王五 男 22 92 赵六 女 19 94 孙七 女 23 ...
- MyBatis 常用写法
MyBatis 常用写法 1.forEach 循环 forEach 元素的属性主要有 item, idnex, collection, open, separator, close. collec ...
随机推荐
- LeetCode题解 Permutations II 和 Permutations I ——回溯算法
这个算法感觉还是很陌生的.算法导论里没有讲这个算法,而数据结构与算法分析只用了一节来阐述.我居然跳过去了..尴尬. 笨方法解决的: 第一题: 给定一个元素不重复的数组,枚举出他们的全排列. 方法1:递 ...
- Django下的templates 和 static静态文件
如果Django顶层目录中没有templates的话,就自己新建一个Directory ,这个文件是存放html文件的 1)如果在views里面用render(request,"" ...
- iOS 证书, provision profile作用
证书(certificate): 给app签名用的,针对开发者,app可以装在真机上的前提条件之一是被签名 Provision profile: 在app包中,用来校验app是否可以被装在真机上,一个 ...
- es6初级之解构----之二 及 键值反转实现
1.解构: 不定参数,扩展表达式 let arr = [100, 201, 303, 911]; let [one, ...others] = arr; console.log(others.leng ...
- 学习笔记2:postman 的基本使用
1.get 请求 请求接口:http://xx.xx.xx.xx/api/user/stu_info 请求参数:stu_name 请求参数是放在请求 URL 里的,点击 Params添加参数,key ...
- Linux安装卸载jdk1.8
首先到官网下载 Linux x64 182.87 MB jdk-8u191-linux-x64.tar.gz https://www.oracle.com/technetwork/java/java ...
- debian9 下编译安装tengine2.2.1
首先下载tengine的源码包,这个大家都会下载吧 wget http://tengine.taobao.org/download/tengine-2.2.1.tar.gz 然后解压缩 tar zxf ...
- window 服务
c#写windows服务 序言 前段时间做一个数据迁移项目,刚开始用B/S架构做的项目,但B/S要寄存在IIs中,而IIs又不稳定因素,如果重启IIs就要打开页面才能运行项目.有不便之处,就改用W ...
- Linux find命令使用方法
Linux中find命令用来在指定目录下查找文件.通过组合不同参数可以在linux系统中快速查找需要的文件或目录. find命令语法 格式:find pathname -options [ -pr ...
- powerdesiner技巧
1.name和code同步问题和name成comments http://blog.csdn.net/huang_xw/article/details/5722981 2.连接数据库