首页 > 其他 > 详细

mybtais xml文件中单个where参数问题

时间:2015-11-10 19:19:35      阅读:567      评论:0      收藏:0      [点我收藏+]

在使用mybaitis传参数的时候,如果仅传入一个类型为String的参数,那么在 xml文件中应该使用 _parameter 来代替参数名。

正确的写法

 <select id="fordetaisCuslineByid" parameterType="java.lang.String" resultType="map">
      SELECT
      <include refid="Base_Column_List"/>
      FROM
      u_custom_line
     WHERE
<!--
        <include refid="SelectSQL"/>
-->
        id = #{id}
    </select>
技术分享
<!--查询的where条件-->
    <sql id="SelectSQL" >
      <where>
          <if test="id != null">
              and id = ${id}
          </if>
          <if test="userMobile != null">
              and user_mobile = #{userMobile}
          </if>
          <if test="startProvinceId != null">
              and start_province_id = #{startProvinceId}
          </if>
          <if test="startCityId != null">
              and start_city_id = #{startCityId}
          </if>
          <if test="startCountyId != null ">
              and start_country_id = #{startCountyId}
          </if>
          <if test="startStation != null">
              and start_station = #{startStation}
          </if>
          <if test="endProvinceId != null">
              and end_province_id = #{endProvinceId}
          </if>
          <if test="endCityId != null">
              and end_city_id = #{endCityId}
          </if>
          <if test="endStation != null ">
              and end_station = #{endStation}
          </if>
          <if test="endCountyId != null">
              and end_county_id = #{endCountyId}
          </if>
          <if test="sendDate != null">
              and send_date = #{sendDate}
          </if>
          <if test="startTime != null">
              and start_time = #{startTime}
          </if>
          <if test="endTime != null ">
              and end_time = #{endTime}
          </if>
          <if test="status != null">
              and status = #{status}
          </if>
          <if test="lineId != null">
              and line_id = #{lineId}
          </if>
          <if test="createTime != null">
              and create_time = #{createTime}
          </if>
          <if test="updateTime != null">
              and update_time = #{updateTime}
          </if>
          <if test="delFlag != null" >
              and delflag = #{delFlag}
          </if>
          <if test="spare1 != null ">
              and spare1 = #{spare1}
          </if>
          <if test="spare2 != null ">
              and spare2 = #{spare2}
          </if>
          <if test="spare3 != null ">
              and spare3 = #{spare3}
          </if>
          <if test="spare4 != null ">
              and spare4 = #{spare4}
          </if>
          <if test="spare5 != null ">
              and spare5 = #{spare5}
          </if>
          <if test="spare6 != null ">
              and spare6 = #{spare6}
          </if>
          <if test="spare7 != null ">
              and spare7 = #{spare7}
          </if>
          <if test="spare8 != null ">
              and spare8 = #{spare8}
          </if>
          <if test="spare9 != null ">
              and spare9 = #{spare9}
          </if>
          <if test="spare10 != null ">
              and spare10 = #{spare10}
          </if>
      </where>
View Code
   <select id="djadjagdjagda" resultType="java.lang.Integer">  
        select count(1)  
        from dadada
        where 1=1  
        <if test="_parameter != null" >  
        and id= #{_parameter,jdbcType=VARCHAR}  
        </if>  
    </select>

 



mybtais xml文件中单个where参数问题

原文:http://www.cnblogs.com/bifenghui/p/4953977.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!