ibatis里出错的代码:
<update id="updateInvestPlan" parameterClass="investPlan" >
update
P_Invest_Plan
set
<isNotNull property="planName">
VC_PLAN_NAME= #planName#,
</isNotNull>
<isNotNull property="planMoney">
L_PLAN_MONEY = #planMoney#
</isNotNull>
where l_id = #id#
</update>
原因:update 表名 set 里 以逗号结尾来了。 当 planMoney 参数为null 时 SQL 就变成了
update
P_Invest_Plan
set
VC_PLAN_NAME= #planName#,
where l_id = #id#
解决办法:
1、最后一个值去掉非空判断(不推荐)
2、使用<set></set>标签 (推荐用这个)