Solve problems sql statement argument is empty (null) does not update parameters

The automatically generated with mybatis

scene:

Modify the page, modify a field, the data before the modification, after modification is empty.

 

mybatis generally used

As :( This simply ignore empty fields, empty fields can not be updated parameters)

<Update id = "" parameterType = "entity classes">

update table set

<if test="字段 !=null ">

Field field = {#, jdbcType = VARCHAR}

</if>

</update>

 

Need to be modified to empty, then write:

Note :( it is to determine if removed, should be noted that as an entity class mybatis automatically generated in all the fields, but here you need to follow the field to write, because if you use some fields to it, does not pass the Senate, he will pass you by default parameter is empty, you do not want to modify the field will also be modified to empty)

<Update id = "" parameterType = "entity classes">

update table set

Field field = {#, jdbcType = VARCHAR}

</update>

Guess you like

Origin www.cnblogs.com/songyinan/p/11649436.html