当前位置: 移动技术网 > IT编程>开发语言>Java > Mybatis和orcale update语句中接收参数为对象的实例代码

Mybatis和orcale update语句中接收参数为对象的实例代码

2019年07月19日  | 移动技术网IT编程  | 我要评论

mybatis的 mapper.xml 中 update 语句使用 if 标签判断对像属性是否为空值。

  userdto是传过来参数的类型,userdto是在mapperdao接口中给更新方法的参数起的别名。

   mapperdao.java

int updata(@param("userdto") userdto userdto);

mapper.xml

<update id="updata" parametertype="userdto">
  update
    table u
  <set>
    <if test=" userdto.age!=null and userdto.age !='' ">
      u.identity = #{userdto.age},
    </if>
    <if test=" userdto.name !=null and userdto.name !='' ">
      u.name = #{userdto.name},
    </if>
   </set>
   <where>
      u.id = #{userdto.id}
  </where>
</update>

总结

以上所述是小编给大家介绍的mybatis和orcale update语句中接收参数为对象的实例代码,希望对大家有所帮助

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网