本篇内容介绍了“ibatis中动态SQL_update的方法是什么”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!
注意:如果<isNotEmpty>是写在一行的话,并且是第一个的话
<isNotEmpty property="realName" prepend=","><![CDATA[ REALNAME = #realName# ]]></isNotEmpty>
内容注意中间加个空格,不然会出现 update role setname=xxx 直接报错
<update id="updateRole" parameterClass="com.mmblue.model.Role"> <![CDATA[ UPDATE role SET gmt_modified = to_date(#gmtModified#,'yyyy-mm-dd hh34:mi:ss'), modifier = #modifier# ]]> <dynamic> <isNotEmpty property="isDeleted" prepend=","> <![CDATA[ is_deleted = #isDeleted# ]]> </isNotEmpty> <isNotEmpty property="roleCode" prepend=","> <![CDATA[ role_code = #roleCode# ]]> </isNotEmpty> <isNotEmpty property="roleName" prepend=","> <![CDATA[ role_name = #roleName# ]]> </isNotEmpty> <isNotEmpty property="deptId" prepend=","> <![CDATA[ dept_id = #deptId# ]]> </isNotEmpty> </dynamic> <![CDATA[ WHERE id = #id# ]]> </update>
2.再来个全部遍历的
<update id="updateUser" parameterClass="com.mmblue.domain.User"> UPDATE MYIVR_TUSER <dynamic prepend="SET "> <isNotEmpty property="realName" prepend=","><![CDATA[ REALNAME = #realName# ]]></isNotEmpty> <isNotEmpty property="password" prepend=","><![CDATA[ PASSWORD = #password# ]]></isNotEmpty> <isNotEmpty property="projectId" prepend=","><![CDATA[ PROJECT_ID = #projectId# ]]></isNotEmpty> <isNotEmpty property="isEable" prepend=","><![CDATA[ ISENABLE = #isEable# ]]></isNotEmpty> <isNotEmpty property="createTime" prepend=","><![CDATA[ CREATETIME = #createTime# ]]></isNotEmpty> <isNotEmpty property="name" prepend=","><![CDATA[ USERNAME = #name# ]]></isNotEmpty> <isNotEmpty property="id" prepend=","><![CDATA[ USERID = #id# ]]></isNotEmpty> <isNotEmpty property="isFirstLogin" prepend=","><![CDATA[ ISFIRSTLOGIN = #isFirstLogin# ]]></isNotEmpty> </dynamic> <dynamic prepend="WHERE"> USERID = #id# </dynamic> </update>
“ibatis中动态SQL_update的方法是什么”的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识可以关注亿速云网站,小编将为大家输出更多高质量的实用文章!
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。