是否可以将 PostgreSQL 中的字符字段转换为 JPA 命名查询中的整数


@Table(name = "Table")
class Table{
 String a
 Integer b
}

此处表 T 中的 A 列是字符变化(32(

我已经尝试了这两种方法,但最终都出错了。

SELECT t.b from Table t where Integer.parseInt(t.a) > 0 
Error : Caused by: org.postgresql.util.PSQLException: ERROR: schema "integer" does not exist

SELECT t.b from Table t where (t.a::integer) > 0 
Error : invalid token :: at line <line number>

谢谢

以下查询对我来说很好用。

SELECT t.b FROM table t WHERE CAST(t.a AS integer) > 0 

最新更新