Update null field solution using Mybatis-plus

Scenes

When using mybatis-plus for data editing, there is a scenario where there is data when adding, and the data needs to be cleared when editing.

Example:
The field cnnvdNumber has a value when it is added. When editing, the cnnvdNumber value is cleared. The value passed by the front end is an empty string "", which requires the database field cnnvdNumber. The value was successfully updated to ""

solution

Involved version

<mybatis-plus.version>3.5.1</mybatis-plus.version>

Add annotations to fields

@TableField(updateStrategy = FieldStrategy.NOT_NULL)

like:

	/**
	 * CNNVD编号
	 */
	@TableField(updateStrategy = FieldStrategy.NOT_NULL)
	private String cnnvdNumber;

Guess you like

Origin blog.csdn.net/u011019141/article/details/127214307
Recommended