在abator中可生成iBatis的代码。其中,Sql_map中带有的两个函数是:

  • updateByPrimaryKeySelective
    只是更新新的model中不为空的字段
  • updateByPrimaryKey
    将为空的字段在数据库中置为NULL

例如

mybatis 中的updateByPrimaryKey与updateByPrimaryKeySelective
CartServiceImpl#update

若DAO中使用的是 updateByPrimaryKeySelective,则按照不为空的值去更新。
如果使用updateByPrimaryKey,这在未定义的字段更新后就没有了。

SQL语句对比分析

mybatis 中的updateByPrimaryKey与updateByPrimaryKeySelective

一系列的isNull判断


mybatis 中的updateByPrimaryKey与updateByPrimaryKeySelective

没有判断,直接加载

相关文章:

  • 2022-12-23
  • 2021-11-04
  • 2022-12-23
  • 2022-03-08
  • 2021-10-07
  • 2021-05-08
  • 2021-10-24
  • 2021-09-21
猜你喜欢
  • 2021-10-29
  • 2021-08-31
  • 2021-06-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案