@Table(name = "Table")
class Table{
String a
Integer b
}
此处表 t 中的列 a 是字符 varying(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
关于java - 是否可以将 PostgreSQL 中的字符字段转换为 JPA 命名查询中的整数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9090830/