mybatis一个select标签执行多个sql语句
2018-01-03 14:23
459 查看
第一步:首先在配置连接池的配置为
d1.url=jdbc:mysql://xxx:3306/djtms?useUnicode=true&characterEncoding=UTF8&allowMultiQueries=true
第二步:
<resultMap id="longMap" type="Long"/> <resultMap id="baseResultMap2" type="map"/> <select id="getPage" resultMap="baseResultMap2,longMap" resultSets="items,count"> select SQL_CALC_FOUND_ROWS <include refid="Base_Column_List"/> from t_area_open <where> <if test="queryParam != null"> <if test="queryParam.rowid != null"> and `rowid` = #{ queryParam.rowid,jdbcType=INTEGER } </if> <if test="queryParam.fid != null"> and fid = #{ queryParam.fid,jdbcType=VARCHAR } </if> <if test="queryParam.fprovinceName != null"> and fprovince_name = #{ queryParam.fprovinceName,jdbcType=VARCHAR } </if> <if test="queryParam.fprovinceCode != null"> and fprovince_code = #{ queryParam.fprovinceCode,jdbcType=TINYINT } </if> <if test="queryParam.fcityName != null"> and fcity_name = #{ queryParam.fcityName,jdbcType=VARCHAR } </if> <if test="queryParam.fcityCode != null"> and fcity_code = #{ queryParam.fcityCode,jdbcType=SMALLINT } </if> <if test="queryParam.fcountyName != null"> and fcounty_name = #{ queryParam.fcountyName,jdbcType=VARCHAR } </if> <if test="queryParam.fcountyCode != null"> and fcounty_code = #{ queryParam.fcountyCode,jdbcType=INTEGER } </if> <if test="queryParam.fstatus != null"> and fstatus = #{ queryParam.fstatus,jdbcType=INTEGER } </if> <if test="queryParam.fcreatetime != null"> and fcreatetime = #{ queryParam.fcreatetime,jdbcType=TIMESTAMP } </if> <if test="queryParam.fupdatetime != null"> and fupdatetime = #{ queryParam.fupdatetime,jdbcType=TIMESTAMP } </if> <if test="queryParam.foperator != null"> and foperator = #{ queryParam.foperator,jdbcType=VARCHAR } </if> </if> </where> limit #{offset},#{rows}; SELECT FOUND_ROWS() AS COUNT; </select>
接口为:
public Collection<Collection<?>> getPage(@Param("queryParam") T t, @Param("offset") int offset, @Param("rows") int rows);
相关文章推荐
- Mybatis+MySql 一个标签中执行多条sql语句
- select语句的结果集直接发向客户端的(一个SQL语句会前后进行各种调用,包括解析(parse)调用、执行(executive)调用、获取(fetch)调用)
- 如何在mybatis中一个insert,delete,update中执行多条SQL语句
- mybatis3下的通用sql的select语句执行类
- MyBatis支持一条标签执行多条sql语句
- 如何在mybatis中一个insert,delete,update中执行多条SQL语句
- 探讨:Oracle数据库查看一个进程是如何执行相关的实际SQL语句
- SQL语句中SELECT语句的执行顺序
- select sql语句执行顺序
- 在mybatis执行SQL语句之前进行拦击处理
- log4j实现显示mybatis执行的sql语句
- Mybatis selectOne方法执行sql有数据返回为null
- mybatis一次可以执行多个sql语句
- mybatis如何直接 执行传入的任意sql语句 并按照顺序取出查询的结果集
- Mybatis中的resultType和resultMap(mybatis执行ddl语句和特殊sql语句)
- optimizer_mode影响一个SQL语句是否可以执行
- mybatis如何在控制台或者tomcat日志中打印出执行的sql语句
- 03_MyBatis基本查询,mapper文件的定义,测试代码的编写,resultMap配置返回值,sql片段配置,select标签标签中的内容介绍,配置使用二级缓存,使用别名的数据类型,条件查询ma
- MySQL-SQL语句中SELECT语句的执行顺序
- 在oracle的PL程序块中执行一个varchar2类型变量中的sql 语句