java Mybatis
查询条件循环且超1000条
查询百度后最终根据业务代码整理,方便自己巩固知识点。
接口:
public class AccountEntity{
List<ModelEntity> getListByOrdersn(List<String> orderNoList);
}
OrderMapper.xml:
<select id="getListByOrdersn" parameterType="java.util.List" resultType="cn.project.gdcommon.view.OrderDetailView">
select f_order_no, to_char(wm_concat(f_days)) days from t_d_order
where 1=1
<if test="list != null && list.size >0">
and f_order_no in
<foreach collection="list" index="index" item="itemso" open="(" close=")">
<if test="index != 0">
<choose>
<when test="index % 1000 ==999">) or f_order_no in (</when>
<otherwise>,<otherwise>
</choose>
</if>
#{itemso}
</foreach>
</if>
group by f_order_no
</select>