mybatis的sql的xml的配置文件中where条件中like的用法。

来源:互联网 发布:知乎 装修 编辑:程序博客网 时间:2024/05/16 10:42

具体文档代码如下:

<?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.hzcominfo.voucher.Faemp">
<cache-ref namespace="com.hzcominfo.dataggr.cloud" />

<select id="selectFaemp" parameterType="String"
resultType="com.hzcominfo.voucher.mapper.zsh.Faemp">
SELECT * FROM FAEMP where gid = #{gid}
</select>

<select id="selectFaempByCriteria" parameterType="net.butfly.albacore.dbo.criteria.Criteria"
resultType="String">
SELECT gid FROM FAEMP <include refid="where" />
</select>

<select id="countFaempByCriteria" parameterType="net.butfly.albacore.dbo.criteria.Criteria"
resultType="long">
SELECT count(gid) FROM FAEMP <include refid="where" />
</select>

<select id="selectFaemps" parameterType="com.hzcominfo.voucher.mapper.zsh.Faemp" 
resultType="com.hzcominfo.voucher.mapper.zsh.Faemp">
SELECT * FROM FAEMP <include refid="where" />
</select>

<sql id="where">
<where>
1 = 1 
<if test="gid!=null and gid!=0"> AND GID=#{gid}</if>
<if test="code!=null"> AND CODE=#{code}</if>
<if test="engName!=null"> AND ENGNAME=#{engName}</if>
<if test="name!=null"> AND NAME like '%${name}%'</if>
<if test="idCard!=null"> AND IDCARD=#{idCard}</if>
<if test="workType!=null"> AND WORKTYPE=#{workType}</if>
<if test="isSysUser!=null and isSysUser!=0"> AND ISSYSUSER=#{isSysUser}</if>
<if test="note!=null"> AND NOTE=#{note}</if>
<if test="src!=null and src!=0"> AND SRC=#{src}</if>
<if test="sndTime!=null"> AND SNDTIME=#{sndTime}</if>
<if test="creator!=null"> AND CREATOR=#{creator}</if>
<if test="createTime!=null"> AND CREATETIME=#{createTime}</if>
<if test="lstUpdOper!=null"> AND LSTUPDOPER=#{lstUpdOper}</if>
<if test="lstUpdTime!=null"> AND LSTUPDTIME=#{lstUpdTime}</if>
<if test="grand!=null"> AND GRAND=#{grand}</if>
<if test="tel!=null"> AND TEL=#{tel}</if>
<if test="fax!=null"> AND FAX=#{fax}</if>
</where>
</sql>


</mapper>

0 0
原创粉丝点击