To fix this issue, you have three options:
1) If you do want to use advanced, dialect specific, SQL functions within JPQL, make sure to make these functions available to your ORM through custom functions and register these with your JPATemplates instance.
2) Use JPASQLQuery instead. This allows you to generate a pure SQL query based on your JPA metamodel.
3) Consider using the Blaze-Persistence QueryDSL integration. Blaze-Persistence is an extension on top of JPA that makes various SQL specific functions like window functions available to JPQL.; nested exception is java.lang.IllegalArgumentException: SQL Expressions like ROWNUMBER are not supported in JPQL - the query language for JPA. SQLExpressions.* can only be used in JPQL queries when these functions are registered as custom function in your ORM.
это то что предлагает библиотека