myibatis判斷爲空更新 小試牛刀

myibatis判斷爲空更新

 

<update id="UpdateOne" parameterType="User">  
     <![CDATA[  	
		 update User
	 ]]>
		<set>
			<if test="user_age!=null">
					user_age=#{userAge},
			</if>
			<if test="user_name!=null">
					userName=#{userName},
			</if>			
		</set>
		<![CDATA[ 
		 	where user_id= #{userId}
		]]>	
 	
    </update>    

 

簡單的例子。。

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章