AuditQuery Hibernate 按分区添加顺序

AuditQuery Hibernate add order by partition

我有 AuditQuery,我想添加 order bypartition by

就像我有:

final AuditReader reader = AuditReaderFactory.get(em);
final List<Test> result = new ArrayList<Test>();

final AuditQuery query =
    reader.createQuery().forRevisionsOfEntity(Test.class, false, true);

我想做类似的事情:

ORDER by (MAX(VALUE) OVER (PARTITION BY ID ORDER BY ID))

如何在 AuditQuery 中完成?

AuditQuery 是建立在 Hibernate Criteria 之上的,所以它不支持 window 函数,在这种情况下你需要写一个原生的 SQL.