xlecho编辑整理,欢迎转载,转载请声明文章来源。欢迎添加echo微信(微信号:t2421499075)交流学习。 百战不败,依不自称常胜,百败不颓,依能奋力前行。——这才是真正的堪称强大!!
传入的值数据结构为:list(map<string, string>)
dao层的代码:
list<recordpo> selectconditionrecord(list<map<string, string>> list);
xml层代码:
<select id="selectconditionrecord" resultmap="baseresultmap" parametertype="java.util.list"> <foreach collection="list" item="item" index="index" separator=";"> select * from record <where> <if test="item.code != null and item.code != ''"> code = #{item.code,jdbctype=varchar} </if> <if test="item.account != null and item.account != ''"> and account = #{item.account,jdbctype=varchar} </if> <if test="item.createdate != null"> and to_char(createdate, 'yyyy-mm-dd') = #{item.createdate,jdbctype=timestamp} </if> </where> </foreach> </select>
mybatis批量更新问题
传入的值数据结构为:list(map<string, string>)
dao层的代码:
void batchupdate(list<recordpo> list);
xml层代码:
<update id="batchupdate" parametertype="java.util.list"> <foreach collection="list" index="index" item="item" separator=";"> update record <set> <if test="item.id != null"> id = #{item.id,jdbctype=varchar}, </if> <if test="item.code != null"> code = #{item.code,jdbctype=varchar}, </if> <if test="item.createuser != null"> createuser = #{item.createuser,jdbctype=varchar}, </if> <if test="item.createdate != null"> createdate = #{item.createdate,jdbctype=timestamp}, </if> </set> <where> id = #{item.id,jdbctype=varchar} </where> </foreach> </update>
cause: java.sql.sqlsyntaxerrorexception: you have an error in your sql syntax; check the manual that corresponds to your mysql server version for the right syntax to use near 'update hd_t_user\n set username ='111' \n where\n ' at line 6\r\n### the error may exist in file;
allowmultiqueries=true
做一个有底线的博客主
如对本文有疑问, 点击进行留言回复!!
解决idea中出现“illegal character U+200B” 问题
荐 为什么加了@Transactional注解,事务没有回滚?
Attribute ‘sklearn.linear_model._logistic.LogisticRegression.multi_class‘ must be explicitly set to
Java/Python实现 LeetCode剑指Offer 14-I.剪绳子(动态规划)
网友评论