You can do the counting in a given field, for example:
getAuditReader().createQuery()
.forRevisionsOfEntity(SomeEntity.class, false, true)
.addProjection(AuditEntity.id().count()).getSingleResult()
Or you can count the version numbers:
getAuditReader().createQuery()
.forRevisionsOfEntity(SomeEntity.class, false, true)
.addProjection(AuditEntity.revisionNumber().count()).getSingleResult()
adamw source
share