#875·Mapper

关于 updateByPrimaryKeySelective(T) 主键异常问题

作者: SMSshuai创建于 2023年2月9日更新于 2025年12月11日

When updating data through the updateByPrimaryKeySelective(T) method, the primary key ID will change. The database primary key ID is incremented. For example, id = 10, 11, 12, 13, and one of the id = 11 was deleted due to business needs. When executing the updateByPrimaryKeySelective method, the id passed in is 12, but after successful execution, the id in the entity becomes 11 (this id data does not exist, and the other data in the entity is normal). After subsequent testing, it was found that after executing this method, if the id of the data is greater than the id of the empty data, an empty data id will be returned. For example: id11 was deleted. Updating data with id < 11 is normal. Updating data with id > 11 will return id = 11. If multiple data is deleted, the first id that is deleted in the correct order will be returned.