In audit table, there is not such a Criteria that we could use Criteria.setProjection(Projections.rowCount())
to get the row count of the query.
We could use AuditQuery to do similar things. But I couldn't find how to set projections in this case. There is also a setProjection
method for AuditQuery, but it takes AuditProjection
as parameter. Is there a similar thing that I could setProjection(rowCount)
?
Thanks
You can do a count on a given field, e.g.:
getAuditReader().createQuery()
.forRevisionsOfEntity(SomeEntity.class, false, true)
.addProjection(AuditEntity.id().count()).getSingleResult()
Or you can count the revision numbers:
getAuditReader().createQuery()
.forRevisionsOfEntity(SomeEntity.class, false, true)
.addProjection(AuditEntity.revisionNumber().count()).getSingleResult()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With