Hibernate Criteria用多列处理的方法



想要用Hibernate标准的方式来处理以下查询,

select * from A where (type, Version) in (select type, max(Version) from A group by type)

只看hibernate标准的方式。请提出建议。

您可以用一个存在的子查询来重新表述它,您可以用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))

最新更新