注解式开发的sql中,if test传的值为0,但还是走进了判断里面,其实是我格式写错了。

@Select({"<script>",
"select id,ifExam,choiceFlag,hotFlag,toIndex,examId,examTarget,examUrl,passScore from OMLOPERMATERIAL where 1=1 ",
"<if test=\"wid!=0\">and id = #{wid} </if>",
"</script>"})
List<JSONObject> selectOmlopermaterial(@Param("wid") int wid);

在test里面 wid直接写就可以了,但我刚开始#{wid!=0}这样的格式。所以出现问题

 

只有当参数都在param里面时,才需要{}, 如下

@Update({"<script>",
"UPDATE study_infomation ",
"<trim prefix=\"SET\" suffixOverrides=\",\">",
"<if test=\"params.dataType!=nulland params.dataType != '' \">dataType=#{params.dataType},</if>",
"</trim> ",
"WHERE id=#{params.id}",
"</script>"
})
void updateDateType(@Param("params") JSONObject params) throws Exception;

 

posted @ 2020-08-28 16:27  RunningNeverStop  阅读(330)  评论(0编辑  收藏  举报