mybatis动态sql中的bind绑定
知识点:bind在模糊查询中的用法
在我的博客 mybatis中使用mysql的模糊查询字符串拼接(like) 中也涉及到bind的使用
<!-- List<Employee> getEmpsTestInnerParameter(Employee employee); -->
<select id="getEmpsTestInnerParameter" resultType="com.hand.mybatis.bean.Employee">
<!-- bind:可以将OGNL表达式的值绑定到一个变量中,方便后来引用这个变量的值 -->
<bind name="bindeName" value="'%'+eName+'%'"/> eName是employee中一个属性值
SELECT * FROM emp
<if test="_parameter!=null">
where ename like #{bindeName}
</if>
</select>
测试类中:
Employee emp=new Employee();
emp.setEname("张"); 为eName属性赋值为“张”
List<Employee> list=mapper.getEmpsTestInnerParameter(emp);
for (Employee employee : list) {
System.out.println(employee);
}
mybatis动态sql中的bind绑定的更多相关文章
- mybatis动态sql中的两个内置参数(_parameter和_databaseId)
mybatis动态sql中的两个内置参数(_parameter和_databaseId) <!-- mybatis动态sql的两个内置参数 不只是方法传递过来的参数可以被 ...
- MyBatis动态SQL中trim标签的使用
My Batis 官方文档 对 动态SQL中使用trim标签的场景及效果介绍比较少. 事实上trim标签有点类似于replace效果. trim 属性 prefix:前缀覆盖并增加其内容 suffix ...
- mybatis动态sql中where标签的使用
where标记的作用类似于动态sql中的set标记,他的作用主要是用来简化sql语句中where条件判断的书写的,如下所示: <select id="selectByParams&qu ...
- mybatis动态SQL中的sql片段
在mybatis中通过使用SQL片段可以提高代码的重用性,如下情景: 1.创建动态SQL <sql id="sql_count">select count(*)< ...
- mybatis动态SQL中的set标签的使用
set标记是mybatis提供的一个智能标记,我一般将其用在修改的sql中,例如以下情况: <update> update user <set> <if test=&qu ...
- mybatis动态sql中foreach标签的使用
foreach标签主要用于构建in条件,他可以在sql中对集合进行迭代.如下: <delete id="deleteBatch"> delete from user w ...
- mybatis动态sql中的sql标签——抽取可重用的sql片段
1.用<sql>标签抽取可重用的sql片段 <!-- 抽取可重用的SQL片段,方便后面引用 1.sql抽取,经常将要查询的列名,或者插入用的列名,之后方便引用 ...
- mybatis动态sql中的trim标签的使用
trim标记是一个格式化的标记,可以完成set或者是where标记的功能,如下代码: 1. select * from user <trim prefix="WHERE" p ...
- mybatis动态sql中的trim标签的使用(转)
trim标记是一个格式化的标记,可以完成set或者是where标记的功能,如下代码: 1. select * from user <trim prefix="WHERE" p ...
随机推荐
- initialize myObject by calling a function that returns an object literal
w作用域控制变量的可见范围. JavaScript: The Good Parts Instead of initializing myObject with an object literal, w ...
- LeetCode_Search Insert Position
Given a sorted array and a target value, return the index if the target is found. If not, return the ...
- ShuffleNet
ShuffleNet (An Extremely Efficient Convolutional Neural Network for Mobile Devices) —— Face++ shuffl ...
- httprunner上传文件multipart/form-data
Content-Type = multipart/form-data#上传文件 Rquest Payload ------WebKitFormBoundarymAyGmnyhpf3UBdec C ...
- spring中的缓存--Caching
1.spring从3.1开始支持缓存功能.spring 自带的缓存机制它只在方法上起作用,对于你使用其他持久化层的框架来讲,是没有影响的,相对来讲这种缓存方式还是不错的选择. 2.提供缓存的接口:or ...
- 脚本其实很简单-windows配置核查程序(1)
先上成品图 需求描述 我们电脑上都安装各种过监控软件,比如360.鲁大师等等...其中有一个功能就是性能监控,在安全行业里面通常叫做"配置核查",目的就是将主机的各种性能指标展示, ...
- 11g ASM新特性
Oracle 11g的ASM有两个有意思的特性,我们看看他们能带给我们什么? 1.Fast mirror resync 原来当diskgroup中的盘发生故障时,Oracle会将这个盘标记为offli ...
- Ajax 报错 500 (Internal Server Error)
==========error======={"readyState":4,"responseText":"<html><head& ...
- React:快速上手(7)——使用中间件实现异步操作
React:快速上手(7)——使用中间件实现异步操作 本文参考链接:Stack Overflow redux-thunk 我们使用store.dispath进行派发时,只能传递一个普通对象进去,如下: ...
- PKU 1655 Balancing Act(树+树的重心)
#include<cstdio> #include<cstring> #include<algorithm> #define maxn 20005 using na ...