mybatis查询参数中既有 实体类参数又有基本类型参数 怎么解决?

浮云疮狗 2015-10-29 10:42:23


页面中只有页数没有数据
...全文
1200 7 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
你可以看下mybatis中可以使用的操作符
浮云疮狗 2015-10-29
  • 打赏
  • 举报
回复
上面最后一张图片有数据库的执行代码 是所有的if条件都执行了 但是我debug的时候 radish里的数据都是通过不了if条件的 就是这一块有问题
  • 打赏
  • 举报
回复
可以用啊,以下是我的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>
  • 打赏
  • 举报
回复
建议:设置日志输出sql语句,看下你的sql语句有没有传值 然后复制sql到数据库去查询看看
浮云疮狗 2015-10-29
  • 打赏
  • 举报
回复
遇到过类似的 请指教 良辰必有重谢
浮云疮狗 2015-10-29
  • 打赏
  • 举报
回复
估计是这种写法不是很对 就是在既有实体类参数和基本类型参数的时候 不能用map
浮云疮狗 2015-10-29
  • 打赏
  • 举报
回复


当Map里面既有实体类 又有基本类的时候就要用类名点了

81,122

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧