将数据库 mysql v5 迁移到 postgres v12 后,Java Spring 应用程序显示以下错误:
错误:运算符不存在: boolean 值 = 整数
提示:没有运算符匹配给定的名称和参数类型。您可能需要添加显式类型转换。
最佳答案
boolean 类型检查因数据库而异(即 mysql 到 postgres)。考虑以下我所经历的例子。
基本实体类 BaseEnity {} 有一列 Activity boolean 类型和 订购 {} 实体类扩展了该类。要选择所有 Activity 订单,mysql 查询是:
select * from Order where active = 1
但是当将数据库迁移到 postgres 时它不起作用。在 postgres 中,它显示错误 运算符不存在:boolean = integer .由于 postgres 期望查询:select * from Order where active = true
因为,postgres 期望 boolean 值 true/false,但在 SQL 查询中,该值被设置为整数类型 1,我们遇到了提示错误。
关于java - 在数据迁移时,出现错误 : operator does not exist: boolean = integer Hint: No operator matches the given name and argument types,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66085915/