HQL - 内部连接错误
HQL - Inner Join Error
我想要 select 具有不同 fieldName
的行。这个查询在 PostgreSQL 中工作得很好。
select f from FieldType as f inner join
(select fa.fieldName, min(fa.id) as id from FieldType fa group by fa.fieldName)
as f1 on f.fieldName =:f1.fieldName and f.id =:f1.id
但我无法使用 HQL
使此查询在 Java
中工作。我总是收到这个错误
org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected token: (
删除括号只会将错误移至下一个字符。我怎样才能解决这个问题?我愿意接受任何建议。
为了利用 HQL,您似乎必须执行某种相关查询:
select f from FieldType as f
where (f.fieldName, f.id) in
(select fa.fieldName, min(fa.id) as id
from FieldType fa
group by fa.fieldName)
我想要 select 具有不同 fieldName
的行。这个查询在 PostgreSQL 中工作得很好。
select f from FieldType as f inner join
(select fa.fieldName, min(fa.id) as id from FieldType fa group by fa.fieldName)
as f1 on f.fieldName =:f1.fieldName and f.id =:f1.id
但我无法使用 HQL
使此查询在 Java
中工作。我总是收到这个错误
org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected token: (
删除括号只会将错误移至下一个字符。我怎样才能解决这个问题?我愿意接受任何建议。
为了利用 HQL,您似乎必须执行某种相关查询:
select f from FieldType as f
where (f.fieldName, f.id) in
(select fa.fieldName, min(fa.id) as id
from FieldType fa
group by fa.fieldName)