1,mybatis,mapper.xml in以及if else的具体实现
在mybatis中,
一)if else在mybatis中的写法
<where>
<!--方式一使用choose的方式查询-->
<!-- <choose>
<when test="parentId !=0 ">parentTypeId=#{parentId}</when>
<when test="parentId==0">parentTypeId is null</when>
</choose> -->
<!--方式二使用if的方式查询-->
<if test="parentId!=0">
parentTypeId=#{parentId}
</if>
<if test="parentId==0">
parentTypeId is null
</if>
</where>
二)mybatis中使用in查询的实现
传入的是list集合
<foreach item="item" index="index" collection="list" open="(" separator="," close=")">
#{item}
</foreach>
传入的是array
<foreach item="item" index="index" collection="array" open="(" separator="," close=")">
#{item}
</foreach>