mybatis 中的稍微复杂些的sql语句:

<?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.creditharmony.core.autoBill.dao.AutoBillTempDao"> <select id="get" resultType="com.creditharmony.core.autoBill.entity.AutoBillTemp">
SELECT * from gl.t_gl_autobill_temp WHERE order_no = #{orderNo}
</select> <insert id="insertBatch">
INSERT INTO gl.t_gl_autobill_temp(user_id, type, order_no, money, status, bill_time, batch_no, bank_info, account_info,account_no,account_name,bill_status,bank_time)
<foreach collection="list" item="item" separator=" union all ">
SELECT #{item.userId}, #{item.type}, #{item.orderNo}, #{item.money}, #{item.status}, to_timestamp(#{item.billTime},'YYYY-MM-DD HH24:MI:SS'), #{item.batchNo}, #{item.bankInfo}, #{item.accountInfo}, #{item.accountNo}, #{item.account_name}, #{item.billStatus}, to_timestamp(#{item.bankTime},'YYYY-MM-DD HH24:MI:SS')
</foreach>
</insert> <insert id="insertHisBatch">
INSERT INTO gl.t_gl_autobill_his(user_id, type, order_no, money, status, bill_time, batch_no, bank_info, account_info,account_no,account_name,bill_status,bank_time)
select user_id, type, order_no, money, status, bill_time, batch_no, bank_info, account_info,account_no,account_name,bill_status,bank_time from gl.t_gl_autobill_temp where order_no in
<foreach collection="list" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</insert> <delete id="deleteAll" parameterType="com.creditharmony.core.autoBill.entity.AutoBillTemp">
DELETE FROM gl.t_gl_autobill_temp
</delete> <delete id="deleteAutoBillTemp" parameterType="com.creditharmony.core.autoBill.entity.AutoBillTemp">
DELETE FROM gl.t_gl_autobill_temp WHERE user_id=#{userId} and type=#{type}
</delete> <delete id="delete">
DELETE FROM gl.t_gl_autobill_temp WHERE order_no=#{orderNo}
</delete> <delete id="deleteBatch" parameterType="java.util.List">
DELETE FROM gl.t_gl_autobill_temp
WHERE order_no in
<foreach collection="list" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</delete> <update id="updateDeductHisStatus">
UPDATE gl.t_gl_deduct_his_detail SET
bill_status = #{billStatus}
WHERE split_id in
<foreach collection="list" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</update>
<update id="updateCollectHisStatus">
UPDATE gl.t_gl_deduct_his_detail SET
collect_status = #{billStatus}
WHERE settlement_no in
<foreach collection="list" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</update>
<update id="updatePayHisStatus">
UPDATE gl.t_gl_pay_his SET
bill_status = #{billStatus}
WHERE item_no in
<foreach collection="list" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</update>
</mapper>

mybatis 中的稍微复杂些的sql语句的更多相关文章

  1. 【mybatis】mybatis执行一个update方法,返回值为1,但是数据库中数据并未更新,粘贴sql语句直接在数据库执行,等待好久报错:Lock wait timeout exceeded; try restarting transaction

    今天使用mybatis和jpa的过程中,发现这样一个问题: mybatis执行一个update方法,返回值为1,但是数据库中数据并未更新,粘贴sql语句直接在数据库执行,等待好久报错:Lock wai ...

  2. 向Oracle中传入数组,批量执行SQL语句

    1.首先用PL/SQL创建package create or replace package excuteBatchOperate as type sqlStr_Array ) index by bi ...

  3. Spring 中jdbcTemplate 实现执行多条sql语句

    说一下Spring框架中使用jdbcTemplate实现多条sql语句的执行: 很多情况下我们需要处理一件事情的时候需要对多个表执行多个sql语句,比如淘宝下单时,我们确认付款时要对自己银行账户的表里 ...

  4. 如何在Oracle中一次执行多条sql语句 (.net C#)

    关键是不能换行,要加上begin ...sql... end;     每个SQL用:隔开,end后面必须加: 以下是拷贝于:http://www.cnblogs.com/teamleader/arc ...

  5. 转载:SQL Server中查询CPU占用高的SQL语句

    SQL Server中查询CPU占用高的SQL语句 SQL Server 表变量的用法 究竟什么是敏捷测试--朱少民

  6. Mybatis中的Mapper.xml映射文件sql查询接收多个参数

    ​ 我们都知道,在Mybatis中的Mapper.xml映射文件可以定制动态SQL,在dao层定义的接口中定义的参数传到xml文件中之后,在查询之前mybatis会对其进行动态解析,通常使用#{}接收 ...

  7. MyBatis学习(三)、动态SQL语句

    三.动态SQL语句 有些时候,sql语句where条件中,需要一些安全判断,例如按某一条件查询时如果传入的参数是空,此时查询出的结果很可能是空的,也许我们需要参数为空时,是查出全部的信息.使用Orac ...

  8. 原!!mybatis如何直接 执行传入的任意sql语句 并按照顺序取出查询的结果集

    需求: 1.直接执行前端传来的任何sql语句,parameterType="String", 2.对于任何sql语句,其返回值类型无法用resultMap在xml文件里配置或者返回 ...

  9. MyBatis7:MyBatis插件及示例----打印每条SQL语句及其执行时间

    Plugins 摘一段来自MyBatis官方文档的文字. MyBatis允许你在某一点拦截已映射语句执行的调用.默认情况下,MyBatis允许使用插件来拦截方法调用 Executor(update.q ...

随机推荐

  1. GridView分页操作

    1.html <PagerStyle HorizontalAlign="Center" /> <PagerTemplate> 第: <asp:Labe ...

  2. HDU 1350

    http://acm.hdu.edu.cn/showproblem.php?pid=1350 给m个顾客的乘车信息,表示几点前上车,要从一个坐标点到达另一个坐标点,花费的时间是两点的曼哈顿距离,两次换 ...

  3. PowerShell 语法结构

    Get-Service -name P* [int]$a = 2 write-output $a [string]$b = "string" write-output $b #$c ...

  4. 《单页Web应用--温故JavaScrpt》学习笔记整理

     变量作用域,函数提升和执行环境对象 1. 变量作用域 在 JavaScript 中,变量 的 作用域 由 函数 限定,即:唯一能定义变量作用域的语块就是 函数. 变量 要么是全局的,要么是局部的. ...

  5. linux安装phpredis扩展

    1.下载扩展安装包 wget   https://github.com/nicolasff/phpredis/downloads 2.解压 tar -zxvf nicolasff-phpredis-2 ...

  6. ZOJ 1007 Numerical Summation of a Series

    原题链接 题目大意:x的取值从0.000到2.000,输出每个x对应的y(x)的值 解法:参考了这篇日志http://www.cnblogs.com/godhand/archive/2010/04/2 ...

  7. Blob 构造函数

    Blob 构造函数使 Web 开发人员可直接在客户端上创建或操作 Blob(经常等效于一个文件). 该构造函数在 W3C 的文件 API 规范中进行定义,该规范目前尚处于工作草案阶段.在较早版本的文件 ...

  8. linux文件系统---10

    进入 Linux 根目录(即“/”, Linux 文件系统的入口, 也是处于最高一级的目录),运行“ls –l”命令,可以看到 Linux 系统包含以下目录. 1./bin 包含基本命令,如 ls.c ...

  9. Codeforces Round #117 (Div. 2)

    Codeforces Round #117 (Div. 2) 代码 Codeforces Round #117 (Div. 2) A. Battlefield any trench in meters ...

  10. HDU 1087 Super Jumping! Jumping! Jumping

    HDU 1087 题目大意:给定一个序列,只能走比当前位置大的位置,不可回头,求能得到的和的最大值.(其实就是求最大上升(可不连续)子序列和) 解题思路:可以定义状态dp[i]表示以a[i]为结尾的上 ...