Hibernate标准是一种使用多列解决问题的方法

Hibernate标准是一种使用多列解决问题的方法,hibernate,hibernate-criteria,Hibernate,Hibernate Criteria,希望以Hibernate标准的方式解决以下查询 select * from A where (type, Version) in (select type, max(Version) from A group by type) 只看hibernate标准的方式。 请提供建议。您可以使用exists子查询重新格式化此查询,您可以使用JPA Criteria API对其进行建模。如下所示: select * from A a where exists (select 1 from A sub gr

希望以Hibernate标准的方式解决以下查询

select * from A where (type, Version) in (select type, max(Version) from A group by type)
只看hibernate标准的方式。
请提供建议。

您可以使用exists子查询重新格式化此查询,您可以使用JPA Criteria API对其进行建模。如下所示:

select * from A a where exists (select 1 from A sub group by sub.type having a.type = sub.type and a.version = max(sub.version))

尝试使用CriteriaBuilder.in,但它不允许多次提供多个列。