mybatis 入门下
来源:互联网 发布:java 文件迁移 编辑:程序博客网 时间:2024/05/29 06:28
1标签
if标签的使用 test后面加OGNLB表达式 c:if test从参数取值判断
<select id="getEmpByConditionIf" resultType="emp">
select *from tabl_emple where
<if test="id!=null">
id=#{id}
</if>
<if test="lastName!=null and lastName!=''">
and last_name like #{lastName}
</if>
<if test="gender==0 or gender==1">
and gender =#{gender}
</if>
<if test="email!=null and email.trim()!=""">
and email =#{email}
</if>
</select>
<choose>标签是选择查询
<choose>
<when test="id!=null">
id=#{id}
</when>
<when test="lastName!=null">
last_name like #{lastName}
</when>
<when test="email!=null">
email =#{email}
</when>
<when test="gender!=null">
gender =#{gender}
</when>
<otherwise>gender=1</otherwise>
</choose>
<foreach></foreach>
内置参数 在xml中 _parameter代表参数 _databaseI就是代表当前数据库别名
bind OGNL绑定到字符串中用在模糊查询
<sql id=“名字”>可抽取sql使用 <include id="名字"> 引用刚才抽取的他的取值是${}
mybatis缓存机制SqlSession 一直开启 与数据库同一次回话查询会放在缓存中,以后需要相同数据直接从缓存拿
失效情况:sqlSession不同 sqlSession相同查询条件不同
二级缓存 一个namespace 对应一个二级缓存
如果回话关闭,一级缓存数据会被保存在2级缓存中,新的回话可以参考2级缓存
内置参数 在xml中 _parameter代表参数 _databaseI就是代表当前数据库别名
bind OGNL绑定到字符串中用在模糊查询
<sql id=“名字”>可抽取sql使用 <include id="名字"> 引用刚才抽取的他的取值是${}
mybatis缓存机制SqlSession 一直开启 与数据库同一次回话查询会放在缓存中,以后需要相同数据直接从缓存拿
失效情况:sqlSession不同 sqlSession相同查询条件不同
二级缓存 一个namespace 对应一个二级缓存
如果回话关闭,一级缓存数据会被保存在2级缓存中,新的回话可以参考2级缓存
- mybatis 入门下
- MyBatis入门
- MyBatis 入门
- myBatis入门
- MyBatis入门
- mybatis入门
- MyBatis入门
- Mybatis入门
- Mybatis入门
- Mybatis入门
- mybatis入门
- Mybatis入门
- mybatis入门
- mybatis入门
- mybatis 入门
- mybatis入门
- Mybatis入门
- mybatis入门
- Sublime Text 3 LESS、SASS、SCSS高亮插件、提示插件
- JAVA作用C3P0创建连接
- Jenkins构建项目,发布远程到服务器(一)
- linux setsockopt函数
- HTML-Link标签
- mybatis 入门下
- QFileSystemModel只显示名称,不显示size,type,modified
- 【剑指Offer】面试题16:反转链表
- Hibernate自关联
- echarts的饼图制作分析
- 20170717
- 【Linux】在Linux中安装bugzilla
- php的crc32函数使用时需要注意的问题(不然就是坑)
- 排序算法合集