如何在 mybatis 生成器中通过配置通过 updateByPrimaryKeySelective 设置 null

问题描述 投票:0回答:2

这是我的 batis 生成器文件:

<table tableName="jxc_stock_journal" enableCountByExample="true"
            enableSelectByPrimaryKey="true" enableSelectByExample="true"
            enableUpdateByPrimaryKey="true" enableDeleteByPrimaryKey="true"
            enableInsert="true" domainObjectName="JxcStockJournal">
            <generatedKey column="id" sqlStatement="MySql"
                identity="true" />
</table>

因此它将生成映射器 xml 文件。在

updateByPrimaryKeySelective
方法中进行空检查:

我需要用

updateByPrimaryKeySelective
将一些字段设置为空,怎么办?

mybatis spring-mybatis mybatis-generator
2个回答
0
投票

您需要使用“updateByPrimaryKey”方法设置一个空值。如您所见,您可以使用“updateByPrimaryKeySelective”来做到这一点。


0
投票

使用

int updateByExampleSelective(@Param("record") PriceActivityApplyDO record, @Param("example") PriceActivityApplyExample example, @Param("selective") PriceActivityApplyDO.Column ... selective);
© www.soinside.com 2019 - 2024. All rights reserved.