PostgreSQL 下 is_deleted 字段问题

Blade 未结 2 14

使用PostgreSQL 18, 设计删除字段 

is_deleted        BOOLEAN     NOT NULL DEFAULT FALSE,                             -- 是否删除


this.saveOrUpdate(entity);

更新时SQL提示: Caused by: org.postgresql.util.PSQLException: 错误: 操作符不存在: boolean = integer

2026-01-26 11:26:28.473 DEBUG 436442 --- [  XNIO-1 task-2] o.s.core.tenant.BladeTenantInterceptor   : original SQL: UPDATE employee  SET account_id=?, staff_number=?,  real_name=?, department_id=?, position_id=?, birth_date=?,  hire_date=?,    employment_type=?, emergency_contact=?, emergency_phone=?,   created_by=?, modified_time=?  WHERE id=? AND is_deleted=0
2026-01-26 11:26:28.475 DEBUG 436442 --- [  XNIO-1 task-2] o.s.core.tenant.BladeTenantInterceptor   : SQL to parse, SQL: UPDATE employee  SET account_id=?, staff_number=?,  real_name=?, department_id=?, position_id=?, birth_date=?,  hire_date=?,    employment_type=?, emergency_contact=?, emergency_phone=?,   created_by=?, modified_time=?  WHERE id=? AND is_deleted=0
2026-01-26 11:26:28.475 DEBUG 436442 --- [  XNIO-1 task-2] o.s.core.tenant.BladeTenantInterceptor   : parse the finished SQL: UPDATE employee SET account_id = ?, staff_number = ?, real_name = ?, department_id = ?, position_id = ?, birth_date = ?, hire_date = ?, employment_type = ?, emergency_contact = ?, emergency_phone = ?, created_by = ?, modified_time = ? WHERE id = ? AND is_deleted = 0
2026-01-26 11:26:28.496 ERROR 436442 --- [  XNIO-1 task-2] o.s.c.l.e.BladeRestExceptionTranslator   : 业务异常

org.springblade.core.log.exception.ServiceException: org.springframework.jdbc.BadSqlGrammarException: 
### Error updating database.  Cause: org.postgresql.util.PSQLException: 错误: 操作符不存在: boolean = integer
  Hint: 没有匹配指定名称和参数类型的操作符. 您也许需要增加明确的类型转换.
  Position: 281
### The error may exist in com/hwkis/berrymall/plm/modules/system/mapper/EmployeeMapper.java (best guess)
### The error may involve com.hwkis.berrymall.plm.modules.system.mapper.EmployeeMapper.updateById-Inline
### The error occurred while setting parameters
### SQL: UPDATE employee SET account_id = ?, staff_number = ?, real_name = ?, department_id = ?, position_id = ?, birth_date = ?, hire_date = ?, employment_type = ?, emergency_contact = ?, emergency_phone = ?, created_by = ?, modified_time = ? WHERE id = ? AND is_deleted = 0
### Cause: org.postgresql.util.PSQLException: 错误: 操作符不存在: boolean = integer
  Hint: 没有匹配指定名称和参数类型的操作符. 您也许需要增加明确的类型转换.
  Position: 281
; bad SQL grammar []
Caused by: org.springframework.jdbc.BadSqlGrammarException: 
### Error updating database.  Cause: org.postgresql.util.PSQLException: 错误: 操作符不存在: boolean = integer
  Hint: 没有匹配指定名称和参数类型的操作符. 您也许需要增加明确的类型转换.
  Position: 281
### The error may exist in com/hwkis/berrymall/plm/modules/system/mapper/EmployeeMapper.java (best guess)
### The error may involve com.hwkis.berrymall.plm.modules.system.mapper.EmployeeMapper.updateById-Inline
### The error occurred while setting parameters
### SQL: UPDATE employee SET account_id = ?, staff_number = ?, real_name = ?, department_id = ?, position_id = ?, birth_date = ?, hire_date = ?, employment_type = ?, emergency_contact = ?, emergency_phone = ?, created_by = ?, modified_time = ? WHERE id = ? AND is_deleted = 0
### Cause: org.postgresql.util.PSQLException: 错误: 操作符不存在: boolean = integer
  Hint: 没有匹配指定名称和参数类型的操作符. 您也许需要增加明确的类型转换.
  Position: 281
; bad SQL grammar []


2条回答
  • 要改成int类型,不能用bool类型,否则会转换失败

    0 讨论(0)
  • 45分钟前

    这个转换是mybatis-plus确定的吗? 可以修改吗

    作者追问:42分钟前

    建议用int,改成int就不需要改bladex其他表的数据,如果你改成bool,那么其他的表也全都要改。

    逻辑删除的默认值可以这里配置:

    mybatis-plus:
      global-config:
        db-config:
          logic-delete-field: flag  # 全局逻辑删除的实体字段名(since 3.3.0,配置后可以忽略不配置步骤2)
          logic-delete-value: 1 # 逻辑已删除值(默认为 1)
          logic-not-delete-value: 0 # 逻辑未删除值(默认为 0)


    0 讨论(0)
提交回复