针对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. IPD术语

    集成产品开发(Integrated Product Development,简称IPD)是一套产品开发的模式.理念与方法. ABC 基于活动的成本核算 ABM 基于活动的管理 ADCP  可获得性决策 ...

  2. php-fpm的参数优化

    查看php-fpm的内存占用 1.查看php-fpm的进程个数 ps -ef |grep "php-fpm"|grep "pool"|wc -l 2.查看每个p ...

  3. HashMap集合-遍历方法

    # HashMap集合-遍历方法 先定义好集合: public static void main(String[] args) { Map<String,String> onemap=ne ...

  4. notepad++一次多行复制粘贴到对应位置

    NodePad++一次复制多行粘贴到对应位置 有时候要写sql,但是里面有很多字段要对应上,如果要自己一个字段一个字段的去写是在有点麻烦,是不是有更好的方法做到这件事呢? 要做这件事,首先分析下我们已 ...

  5. 剑指offer47:位运算+递归。求1+2+3+...+n,要求不能使用乘除法、for、while、if、else、switch、case等关键字及条件判断语句(A?B:C)。

    1 题目描述 求1+2+3+...+n,要求不能使用乘除法.for.while.if.else.switch.case等关键字及条件判断语句(A?B:C). 2 思路和方法 (1)递归,不能使用if等 ...

  6. RabbitMQ安装&简单使用

    .什么是RabbitMQ.详见 http://www.rabbitmq.com/. 作用就是提高系统的并发性,将一些不需要及时响应客户端且占用较多资源的操作,放入队列,再由另外一个线程,去异步处理这些 ...

  7. HeidiSQL 导入Excel数据

    一 前言 原文出处:http://blog.csdn.net/qq_27727681/article/details/53944744 二 效果演示: 2000多条数据,顺利导入成功. 三  实现方法 ...

  8. StoneTab标签页CAD插件 3.0.0

    //////////////////////////////////////////////////////////////////////////////////////////////////// ...

  9. servlet报错“严重: Allocate exception for servlet 类名java.lang.ClassNotFoundException: 路径. 类名”可能原因

    1.WEB-INF下web.xml中<servlet-class>路径错误,正确路径为 <servlet-class>包名.类名</servlet-class> 2 ...

  10. 选择webpack这条路,我踩过的坑

    在http://www.jianshu.com/p/42e11515c10f这篇文章,我重新学习了一下webpack. 一.json文件里面不应该含有注释,否则会报错 本来我的json文件长这个样子: ...