当前位置: 代码迷 >> Java Web开发 >> mybatis查询参数中既有 实体类参数又有基本类型参数 如何解决
  详细解决方案

mybatis查询参数中既有 实体类参数又有基本类型参数 如何解决

热度:87   发布时间:2016-04-13 22:14:40.0
mybatis查询参数中既有 实体类参数又有基本类型参数 怎么解决?


页面中只有页数没有数据   
 
------解决思路----------------------
可以用啊,以下是我的mybatis写法

<select id="queryOrderPage" resultMap="BaseResultMap" parameterType="map">
   select 
   <include refid="Base_Column_List" />
   from  t_order  where 
   <![CDATA[ status <> 99 ]]>
   <if test="orderId != null and orderId != ''">
   and order_id = #{orderId,jdbcType=BIGINT}
   </if>
   <if test="orderItem != null and orderItem.size() > 0">
   and order_id in 
   <foreach item="item" index="index" collection="orderItem" open="(" separator="," close=")">
            #{item}
        </foreach>
   </if>
   <if test="fromOrderId != null and fromOrderId != ''">
   and order_type_id = #{fromOrderId,jdbcType=BIGINT}
   </if>
   <if test="startFinDate != null and startFinDate != ''">
   <![CDATA[  and Date(create_time) >= #{startFinDate,jdbcType=TIMESTAMP} ]]>
   </if>
   <if test="endFinDate != null and endFinDate != ''">
   <![CDATA[  and Date(create_time) <= #{endFinDate,jdbcType=TIMESTAMP} ]]>
   </if>
   <if test="buyOrgIds != null and buyOrgIds.size() > 0">
   and buy_org_id  in
   <foreach item="item" index="index" collection="buyOrgIds" open="(" separator="," close=")">
            #{item}
        </foreach>
   </if>
   <if test="sellOrgIds != null and sellOrgIds.size() > 0">
   and sell_org_id  in
   <foreach item="item" index="index" collection="sellOrgIds" open="(" separator="," close=")">
            #{item}
        </foreach>
   </if>
   <if test="orderStatus !=null and orderStatus != ''">
   and status = #{orderStatus,jdbcType=TINYINT}
   </if>
   <if test="trnsctWay !=null and trnsctWay != ''">
      and trnsct_way_id = #{trnsctWay,jdbcType=TINYINT}
   </if>
   <if test="loginOrgId != null and loginOrgId != ''"> 
   and sell_org_id = #{loginOrgId,jdbcType=INTEGER}
   </if>
   order by  lst_upd_time desc limit #{offset}, #{limit}
  </select>
  相关解决方案