While HQL supports scalar functions (see user guide 15.27) the envers query API does not support them.
I suggest to change the signature of the method AuditProperty.function(String) to return an AuditProperty instead of an AuditProjection. Since AuditProperty implements AuditProjection this would not break existing code. However this change will break binary compatibility, is this a problem?
Sorry for the long delay but now I have finished work on this issue. I have created a PR: https://github.com/hibernate/hibernate-orm/pull/1849
After a little bit more analysis i realized that my initial approach by extending AuditProperty.function(String) would not support all possible functions. I implemented a more flexible approach. For details see the javadoc on AuditEntity.function or the provided unit tests. Lets me know if I should do any more adaptions to the code base before the PR could be accepted.
@Chris Cranford Can I still push changes to this PR? I'd like to add the possibility to apply the like operator on a function criterion. I also would like to add the possiblity to use the id of an entity as function argument.
, Sure knock yourself out
@Chris Cranford, I've pushed an additional commit, thanks!
, we intend to deprecate and in some cases remove a few things in ORM6 so in order to prepare Envers for this, I am adding our own MatchMode implementation to replace the one used from org.hibernate.criterion. Once I push that to master, I'll update your PR to use that implementation instead. Just thought I'd let you know.