- HQL supports EXTRACT(... FROM ...) function, and EPOCH keyword although it is not mentioned in documentstion.
- HQL also supports no-argument LOCALTIMESTAMP function (for Postgres and MySQL dialects). This fact also is not in documentation, but I found it in sources (link1, link2)
So, required HQL query is:
FROM SomeEntity p WHERE EXTRACT(EPOCH FROM (LOCALTIMESTAMP-p.storageTime))/3600 > :threshold