1.实体中忽略不映射的字段
import javax.persistence.Transient;
@Transient
2.传入字符串分割成数组
ids:1,2,3
<if test="@Ognl@isNotEmpty(ids)">
AND id in
<foreach collection="ids.split(',')" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
3.模糊查询
<if test="@Ognl@isNotEmpty(fullText)">
AND (
LOWER(t1.name) like LOWER(concat('%',#{fullText},'%'))
OR LOWER(t1.studNo) like LOWER(concat('%',#{fullText},'%'))
)
</if>
4.传递多个以,隔开的参数_parameter.split(',')
<update id="updateUseTimes">
update t_paper set useTimes = (useTimes+1) WHERE id in
<foreach collection="_parameter.split(',')" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</update>
网友评论