mybatis include choose when if
来源:互联网 发布:linux搭建邮件系统 编辑:程序博客网 时间:2024/05/18 01:04
<?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.hundsun.cloudtrade.match.dao.IDayHoldDao"><sql id="insertIntoHoldSql">INSERT INTO tb_day_hold (firm_account ,seat_no ,stock_account ,exchange_type ,stock_name ,stock_code ,amount ,market_value ,position_str )VALUES (#{firm_account } ,#{seat_no } ,#{stock_account } ,#{exchange_type } ,#{stock_name } ,#{stock_code } ,<choose><when test="occur_amount != null and occur_amount != '' ">#{occur_amount } , </when><when test="amount != null and amount != '' ">#{amount } , </when><otherwise>0,</otherwise></choose>#{market_value } ,#{position_str } )</sql><insert id="addOrUpdateOne_addAmount" parameterType="com.hundsun.cloudtrade.match.domain.DayHoldDomain"><include refid="insertIntoHoldSql"></include><![CDATA[ON DUPLICATE KEY UPDATEamount = amount + VALUES(amount);]]></insert><insert id="addOrUpdateOne_amount" parameterType="com.hundsun.cloudtrade.match.domain.DayHoldDomain"><include refid="insertIntoHoldSql"></include><![CDATA[ON DUPLICATE KEY UPDATEamount = VALUES(amount) , seat_no = VALUES(seat_no);]]></insert><select id="qryMultiRecords"parameterType="com.hundsun.cloudtrade.match.dto.req.QryHoldReq"resultType="com.hundsun.cloudtrade.match.domain.DayHoldDomain">SELECT firm_account ,seat_no ,stock_account ,exchange_type ,stock_name ,stock_code ,amount ,market_value ,position_str <choose><!-- 查询历史持仓表 --> <when test="hold_date != null and hold_date != '' "> ,hold_date FROM tb_history_hold </when> <!-- 查询当日持仓 --> <otherwise> ,'' hold_date FROM tb_day_hold </otherwise> </choose> WHERE firm_account = #{firm_account} <if test="seat_no != null and seat_no != '' "> AND seat_no = #{seat_no} </if> <if test="exchange_type != null and exchange_type != '' "> AND exchange_type = #{exchange_type} </if> <if test="stock_account != null and stock_account != '' "> AND stock_account = #{stock_account} </if> <if test="position_str != null and position_str != '' "> AND position_str = #{position_str} </if> ORDER BY stock_code DESC<if test="req_number != null and req_number != '' "> LIMIT 0,#{req_number} </if> ;</select><delete id="delMultiRecords" parameterType="com.hundsun.cloudtrade.match.dto.req.DelHoldsReq"><![CDATA[DELETE FROM tb_history_hold WHERE firm_account = #{firm_account};DELETE FROM tb_day_hold WHERE firm_account = #{firm_account};]]></delete></mapper>
数据源的配置:
jdbc.url=jdbc:mysql://10.20.135.32:8066/TESTDB?autoReconnect=true&allowMultiQueries=truejdbc.username=rootjdbc.password=123456jdbc.driverClass=com.mysql.jdbc.Driver
注意 allowMultiQueries=true 说明允许了多个 sql 语句的同时操作
阅读全文
0 0
- mybatis include choose when if
- mybatis choose when用法
- MyBatis choose(when, otherwise)标签
- Mybatis choose (when, otherwise)标签
- Mybatis choose (when, otherwise)标签
- MyBatis-动态SQL的if、choose、when、otherwise、trim、where、set、foreach使用
- MyBatis-动态SQL的if、choose、when、otherwise、trim、where、set、foreach使用
- mybatis-动态sql-if,choose,when,otherwis,trim,where,set,foreach,test,bind
- mybatis 的<choose> <when>标签和<if test >标签的区别
- mybatis if choose ifelse 使用
- [c.y.j]mybatis choose when otherwise
- mybatis where,foreach,choose when ,set
- Mybatis 动态加载sql when otherwise choose 理解成if else 条件中可以把传来的参数当变量
- Mybatis <where> <if> <set> <trim> <choose>标签
- Mybatis最入门---动态查询(choose,when,otherwise)
- Mybatis最入门---动态查询(choose,when,otherwise)
- mybatis语句中使用choose when和otherwise
- Mybatis最入门---动态查询(choose,when,otherwise)
- big data 文章汇总
- 第7周项目1-建立顺序环形队列算法库
- Median of sorted arrays解题报告
- Failed to import pydot. You must install pydot and graphviz...-keras使用pydot出错(ubuntu16.04)
- 第8周【项目2
- mybatis include choose when if
- oracle导入dmp备份文件
- web前端开发笔记:JavaScript面向对象总结
- EventBus
- Codeforces Round #440 C. Maximum splitting
- 登陆网页验证
- OpenGL学习: 帧缓冲对象(Frame Buffer Object)
- 使用腾讯云 SCF 云函数压缩 COS 对象存储文件
- ST官方库函数之GPIO复位函数void GPIO_DeInit(GPIO_TypeDef* GPIOx) 的理解