PostgreSQL 下 is_deleted 字段问题

Blade 未结 1 109
tongyi
tongyi 剑侠 2026-01-26 11:34

使用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 []


1条回答
  • 2026-01-26 12:03

    要改成int类型,不能用bool类型,否则会转换失败

    0 讨论(0)
提交回复