针对in字句中的数组使用方法

<select id="getCpProfileNamesByIds" resultType="string">
select name from mega_mis_smpp where id in
<foreach item="ids" index="index" collection="array" open="(" separator="," close=")">
#{ids}
</foreach>
</select>

针对in字句中的Collection使用方法

存储过程的使用:

 <select id="FactoryNumberDao.getNewFactoryCode" resultMap="BaseResultMap" >
DECLARE @factoryCode varchar(5)
EXEC P_Factory_Number
@factoryCode = @factoryCode OUTPUT
SELECT @factoryCode as factoryCode
</select>

Ognl的使用:

 <select id="AreaDao.findByPageArea.count"
resultType="java.lang.Long">
SELECT count(*) from gs_area
<include refid="areaDaoDynamicWhere"/> </select> <sql id="areaDaoDynamicWhere">
<!--
ognl访问静态方法的表达式
为@class@method(args),以下为调用框架中的Ognl.isNotEmpty()方法,还有其它方法如isNotBlank()可以使用,具体请查看Ognl类
-->
<where>
<!-- del_flag = '0' -->
<if test="@Ognl@isNotEmpty(areaCode)">
and area_code = #{areaCode}
</if>
<if test="@Ognl@isNotEmpty(areaName)">
and area_name like '%${areaName}%'
</if>
</where>
</sql>

sql标签:

<sql id="Base_Column_List" >
factory_code, factory_name, factory_user, factory_desc, tel, email, update_time,
state_flag
</sql>
<select id="FactoryDao.selectByPrimaryKey" resultMap="FactoryInfoMap" parameterType="java.lang.String" >
select
<include refid="Base_Column_List" />
from dbo.gs_factory
where factory_code = #{factoryCode,jdbcType=VARCHAR}
</select>
<select id="LineDao.findByPageLine.count"
resultType="java.lang.Long">
SELECT count(*) from gs_line
<include refid="lineDaoDynamicWhere"/>
</select>
<sql id="lineDaoDynamicWhere">
<!--
ognl访问静态方法的表达式
为@class@method(args),以下为调用框架中的Ognl.isNotEmpty()方法,还有其它方法如isNotBlank()可以使用,具体请查看Ognl类
-->
<where>
<!-- del_flag = '0' -->
<if test="@Ognl@isNotEmpty(lineCode)">
and line_code = #{lineCode}
</if>
<if test="@Ognl@isNotEmpty(lineName)">
and line_name like '%${lineName}%'
</if>
</where>
</sql>
<sql id="stationTaskReportChartDynamicWhere">
<!--
ognl访问静态方法的表达式
为@class@method(args),以下为调用框架中的Ognl.isNotEmpty()方法,还有其它方法如isNotBlank()可以使用,具体请查看Ognl类
-->
<choose>
<when test="endDate!=null and startDate!=null">
and g.plan_task_date BETWEEN #{startDate,jdbcType=TIMESTAMP} AND #{endDate,jdbcType=TIMESTAMP}
</when>
<when test="endDate==null and startDate!=null">
and g.plan_task_date >= #{startDate,jdbcType=TIMESTAMP}
</when>
<when test="endDate!=null and startDate==null">
<![CDATA[
and g.plan_task_date <= #{startDate,jdbcType=TIMESTAMP}
]]>
</when>
</choose>
<if test="stationCodeList!=null">
and g.station_code in
<foreach item="stationCode" index="index" open="(" close=")" separator="," collection="stationCodeList">
#{stationCode}
</foreach>
</if>
<if test="userCodeList!=null">
and g.user_code in
<foreach item="userCode" index="index" open="(" close=")" separator="," collection="userCodeList">
#{userCode}
</foreach>
</if>
</sql>  

trim标签的使用:

  <insert id="AssetTypeDao.insert" parameterType="com.easyway.eamsg.assetmgt.domain.AssetTypeInfo" >
insert into dbo.gs_asset_type
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="assetTypeCode != null" >
asset_type_code,
</if>
<if test="assetTypeName != null" >
asset_type_name,
</if>
<if test="assetTypeDesc != null" >
asset_type_desc,
</if>
<if test="natureFlag != null" >
nature_flag,
</if>
<if test="featureFlag != null" >
feature_flag,
</if>
<if test="codingFlag != null" >
coding_flag,
</if>
<if test="matchFlag != null" >
match_flag,
</if>
<if test="updateTime != null" >
update_time,
</if>
<if test="stateFlag != null" >
state_flag,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="assetTypeCode != null" >
#{assetTypeCode,jdbcType=VARCHAR},
</if>
<if test="assetTypeName != null" >
#{assetTypeName,jdbcType=VARCHAR},
</if>
<if test="assetTypeDesc != null" >
#{assetTypeDesc,jdbcType=VARCHAR},
</if>
<if test="natureFlag != null" >
#{natureFlag,jdbcType=CHAR},
</if>
<if test="featureFlag != null" >
#{featureFlag,jdbcType=CHAR},
</if>
<if test="codingFlag != null" >
#{codingFlag,jdbcType=CHAR},
</if>
<if test="matchFlag != null" >
#{matchFlag,jdbcType=CHAR},
</if>
<if test="updateTime != null" >
#{updateTime,jdbcType=TIMESTAMP},
</if>
<if test="stateFlag != null" >
#{stateFlag,jdbcType=CHAR},
</if>
</trim>
</insert>

set标签的使用

 <update id="AssetTypeDao.update" parameterType="com.easyway.eamsg.assetmgt.domain.AssetTypeInfo" >
update dbo.gs_asset_type
<set >
<if test="assetTypeName != null" >
asset_type_name = #{assetTypeName,jdbcType=VARCHAR},
</if>
<if test="assetTypeDesc != null" >
asset_type_desc = #{assetTypeDesc,jdbcType=VARCHAR},
</if>
<if test="natureFlag != null" >
nature_flag = #{natureFlag,jdbcType=CHAR},
</if>
<if test="featureFlag != null" >
feature_flag = #{featureFlag,jdbcType=CHAR},
</if>
<if test="codingFlag != null" >
coding_flag = #{codingFlag,jdbcType=CHAR},
</if>
<if test="matchFlag != null" >
match_flag = #{matchFlag,jdbcType=CHAR},
</if>
<if test="updateTime != null" >
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
<if test="stateFlag != null" >
state_flag = #{stateFlag,jdbcType=CHAR},
</if>
</set>
where asset_type_code = #{assetTypeCode,jdbcType=VARCHAR}
</update> 

存储过程:

   <select id="SiteAssetsSoftWareNumberDao.getNewsiteAssetsSoftwareCode" resultMap="BaseResultMap" parameterType="com.easyway.eamsg.assetmgt.domain.SiteAssetsSoftWareNumbeInfo" >
DECLARE @siteAssetsSoftwareCode varchar(13)
EXEC P_Site_Assets_Software_Number
@stationCode = #{stationCode,jdbcType=VARCHAR},
@assetTypeCode = #{assetTypeCode,jdbcType=VARCHAR},
@siteAssetsSoftwareCode = @siteAssetsSoftwareCode OUTPUT
SELECT @siteAssetsSoftwareCode as siteAssetsSoftwareCode
</select>

存储过程2:

  <resultMap id="BaseResultMap" type="com.easyway.eamsg.assetmgt.domain.SparePartsNumbeInfo" >
<id column="id" property="id" jdbcType="INTEGER" />
<result column="remarks" property="remarks" jdbcType="VARCHAR" />
<result column="sparePartsCode" property="sparePartsCode" jdbcType="VARCHAR" />
</resultMap>
<select id="SparePartsNumberDao.getNewSparePartsCode" resultMap="BaseResultMap" >
DECLARE @sparePartsCode varchar(17)
EXEC P_Spare_Parts_Number
@sparePartsCode = @sparePartsCode OUTPUT
SELECT @sparePartsCode as sparePartsCode
</select>

mybayis项目使用的Mapping文件使用总结参考(二)的更多相关文章

  1. Mybayis的项目使用的Mapping文件使用总结参考(一)

    作者:longgangbai 以前用过ibatis2,但是听说ibatis3有较大的性能提升,而且设计也更合理,他不兼容ibatis2.尽管ibatis3还是beta10的状态,但还是打算直接使用ib ...

  2. 使用mybatis-generator自动生成model、dao、mapping文件

    参考文献:http://www.cnblogs.com/smileberry/p/4145872.html 一.所需库 1.mybatis-generator库 2.连接DB的驱动(此以mysql为例 ...

  3. Android项目实战(二十四):项目包成jar文件,并且将工程中引用的jar一起打入新的jar文件中

    前言: 关于.jar文件: 平时我们Android项目开发中经常会用到第三方的.jar文件. 其实.jar文件就是一个类似.zip文件的压缩包,里面包含了一些源代码,注意的是.jar不包含资源文件(r ...

  4. ANDROID STDUIO 项目里的R文件突然丢失的解决办法N种之一

    刚刚项目里的R文件突然挂了,清理项目,关闭重开Studio,都不能解决.快没折了. 然后只好在项目上右击,看看有没有解决的办法.发现有个 Make Module ,姑且试试吧. 结果,竟然修复了.这是 ...

  5. chrome调试本地项目, 引用本地javascript文件

    chrome调试本地项目, 引用本地javascript文件 本地文件可以访问本地文件 修改快捷方式属性 C:\Users\xxx\AppData\Local\Google\Chrome\Applic ...

  6. 解决eclipse+git中每次clean项目需要重新commit文件

    使用.gitignore文件避免每次clean项目需要重新commit文件(XX.xcodeproj/project.xcworkspace/xcuserdata/XX.xcuserdatad/Use ...

  7. delphi项目中的modelsupport文件夹

    delphi项目中的modelsupport文件夹 今天写着写着突然发现多了一个这个文件夹..苦思不得其解  看着又难受  删了又重建 终于找到了  存此备查;Tools--option--toget ...

  8. iOS之多控制器管理--项目中的常见文件

    项目中的常见文件 内容大纲: 1.LaunchScreen 2.info.plist文件 3.pch文件 1.LaunchScreen xcode5和xcode6区别 1.xcode6没有Framew ...

  9. PTPX中的activity文件以及mapping文件

    在不同的simulation中的capturing switching activity: SAIF:Switching Activity Interface Format,包含toggle coun ...

随机推荐

  1. shell 监控

    #!/bin/shsource /etc/profileserverName=$1dingDingName=$2 #获取内存情况memory=(`free | awk 'NR==2{print $2, ...

  2. RAMSPEED的简单测试数据 x86虚拟机 龙芯 飞腾

    1. ramspeed 简介 http://alasir.com/software/ramspeed/ 官网为 2. 进行简单安装测试的步骤 . 下载 wget http://alasir.com/s ...

  3. 自定义的C4P数据库连接池

    要想自己写一个数据库连接池 需要实现DataSoure这个类,然后重写getConnection 这个方法 public class C4p0 implements DataSource{ priva ...

  4. Spring Boot 创建动态定时任务

    1,日期格式转换 //定时任务格式转换public static String convertCronTime(Date jobDate){ //https://blog.csdn.net/qq_39 ...

  5. python搞搞大数据之hbase——初探

    使用python链接mysql读入一个表并把它再写到hbase 里去(九头蛇万岁) 先声明一下需要用的库: 俩!!: happybase    (写这个的老哥真的happy) pymysql 建议使用 ...

  6. win10现在安装redis

    一.下载: 下载地址: https://github.com/MicrosoftArchive/redis/releases 根据系统下载的版本:以(64位为例) 下载后一般解压到根目录下:如(E:\ ...

  7. P2279 消防局的设立 (树形DP or 贪心)

    (点击此处查看原题) 树形DP写法 看到这个题的要求,很容易相到这是一个树形DP的问题,但是dp数组应该如何设计并转移才是关键 dp[i][0]代表当前结点可以向上覆盖2层,自身一定被覆盖dp[i][ ...

  8. dedecms发布文章时间显示多少分钟前

    /**文章发布多少时间前*/function tranTime($time) { $rtime = date("m-d H:i",$time); $htime = date(&qu ...

  9. Thinkphp解决phpExcel导出数据量大导致内存溢出

    工作需要导出几万的数据量.操作比较频繁.之前数据在七八千是数据导出很慢.phpExcel是方便但是性能一般.现在改为使用csv导出数据:可以缓解内存压力,一次导出两三万是没问题的.当然服务器内存给力, ...

  10. springboot-异步、发送邮件(一)

    pom.xml <!--邮件javax.mail--> <dependency> <groupId>org.springframework.boot</gro ...