mybatis 一点整理
mapper指定对应的接口
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="xx.xx.xx.dao.xxMapper">
多指定几个
<sql id="someXXXFields">
x.id as id,
x.name as name,
x.age as age,
...
</sql>
select 子句在写具体查询语句时候可以灵活拼接
<select id="getMessage" parameterType="String" resultMap="xxResultMap">
select
<include refid="someXXXFields"/>
,
<include refid="someYYYFields"/>
from XXX x left join YYY y on x.id = y.id
<where>
<include refid="conditionWhere"/>
</where>
</select>
那么显然where子句也能进行指定 (1) if test (2) foreach collection
<sql id="orderWhere">
<if test="orderNum!=null">
and x.order_num = #{orderNum}
</if>
<if test="orderNumList!=null">
and x.order_num in
<foreach collection="orderNumList" item="orderNum" open="(" separator="," close=")">
#{orderNum}
</foreach>
</if>
</sql>
choose when otherwise
<choose>
<when test="country != null">
and country = #{country}
</when>
<otherwise>
and country is null
</otherwise>
</choose>
<?xml version="1.0" encoding="UTF-8" ?><!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"><mapper namespace="com.qunar.hotel.otatts.provider.order.dao.OrderInfoMapper">
mybatis 一点整理的更多相关文章
- 关于MyBatis sqlSession的一点整理
工作中,需要学习一下MyBatis sqlSession的产生过程,翻看了mybatis-spring的源码,阅读了一些mybatis的相关doc,对mybatis sqlSession有了一些认知和 ...
- MYBATIS 简单整理与回顾
这两天简单整理了一下MyBatis 相关api和jar包这里提供一个下载地址,免得找了 链接:http://pan.baidu.com/s/1jIl1KaE 密码:d2yl A.简单搭建跑项目 2.进 ...
- MyBatis知识点整理
1.MyBatis一般使用步骤 1.1获取Configuration实例或编写配置文件 //获取Configuration实例的样例 TransactionFactory transactionFac ...
- Mybatis面试整理
#{}和${}的区别 #{}是预编译处理,${}是字符串替换. Mybatis在处理#{}时,会将sql中的#{}替换为?号,调用PreparedStatement的set方法来赋值: Mybatis ...
- 一:MyBatis知识整理(1)
一:MyBatis的架构 1.mybatis配置SqlMapConfig.xml,此文件作为mybatis的全局配置文件,配置了mybatis的运行环境等信息. mapper.xml文件即sql映射文 ...
- 三:Mybatis知识整理(3)
一:mybatis中模糊查询的方法: 1.直接传参法:在java传参时进行拼接 -- %keyword% 2.mysql内置函数:concart('%',#{keyword},'%') -- 拼接sq ...
- 关于Java IO InputStream 的一点整理!
程序的开发其中一直在用文件的读写.可是对于java其中输入流以及输出流仅仅是会用不理解,一直以来想搞清楚其,可是一直没有运行(悲剧).今天早上抽出半个小时通过JDK API1.6.0中文版帮助逐步的了 ...
- mybatis问题整理
// List<String> findBuildByProject(String prjName); //单参数时使用<if></if>标签判断采用"_ ...
- Mybatis入门及第一个Mybatis程序
Mybatis笔记整理 所需要的基础知识 JDBC Mysql Java基础 Maven Junit 框架:是有配置文件的.最好的方式:看官网文档 1.简介 1.1.什么是MyBatis 简介 什么是 ...
随机推荐
- 【NOIP2011提高组】选择客栈
题目不附了,是一个单纯的ST模型,但是考验各种常数优化. 最大的优化是对于同颜色的客栈来说,如果1号和2号成功配对了,那么1和3,1和4都可以成功配对,那么只要找到一对成功配对的,我们就直接加上剩下的 ...
- [SQL基础教程] 3-3 HAVING
[SQL基础教程] 3-3 HAVING HAVING子句 SELECT col_1,col_2 FROM table GROUP BY col_1,col_2 HAVING col_1 = '2'; ...
- asp.net mvc 上传下载文件的几种方式
view: <!DOCTYPE html> <html> <head> <meta name="viewport" content=&qu ...
- openwrt 更改默认主题
BB 版本默认的主题为 bootstrap,想要修改为其他的主题,可以按照如下方法修改: 1.查看可以使用的主题. "make menuconfig" ---> " ...
- Ubuntu 12.04 修改键盘映射
背景: (1) 我的笔记本G450上,Page_up/Page_down键分别和Home/End在同一个键位上,需要同时按住Fn键才能敲出Home/End (2) 习惯用Vim的同志都有这个感觉,Es ...
- webapi mvc路由注册
在VS.NET 2013中,新建WebAPI项目,代码总的 GlobalConfiguration.Configure(WebApiConfig.Register); 编译时会提示:System.We ...
- <蛇形填数>--算法竞赛 入门经典(第2版)- 3.1 数组 程序3-3 蛇形填数
蛇形填数: 在n×n方阵里填入1,2,....,n×n,要求填成蛇形.例如,n = 4 时方阵为: 10 11 12 1 9 16 13 2 8 15 14 3 7 ...
- PHP之APC缓存详细介绍(学习整理)
APC的介绍 The Alternative PHP Cache (APC) is a free and open opcode cache for PHP. Its goal is to provi ...
- Revenge of GCD HDU5019
Description In mathematics, the greatest common divisor (gcd), also known as the greatest common fac ...
- hdfs格式化hadoop namenode -format错误
在对HDFS格式化,执行hadoop namenode -format命令时,出现未知的主机名的问题,异常信息如下所示: [shirdrn@localhost bin]$ hadoop namenod ...