mybatisplus--getOne and logical deletion problem detailed explanation

1.getOne

If there are multiple query results, an exception will be thrown at this time

By default, getOne throws an exception directly when there are multiple query results, and the bottom layer calls the overloaded method getOne(Wrapper queryWrapper, boolean throwEx)
insert image description here

The overloaded method getOne(Wrapper queryWrapper, boolean throwEx) executes different methods according to whether the input parameter throws an exception. If the second parameter is true, the method will be executed directly
;

insert image description here
insert image description here

Tombstone @TableLogic

  1. An annotation @TableLogic needs to be added on the deleted field

  2. Write the configuration in the configuration file

 global-config:
  db-config:
   logic-delete-value: 1 # 逻辑已删除值(默认为 1)
   logic-not-delete-value: 0 # 逻辑未删除值(默认为 0)

Guess you like

Origin blog.csdn.net/yzx3105/article/details/109448705