From Hibernate Query Spaces - Optimizing Flush and Cache Operations:
Since Hibernate 5.3.20 and 5.4.24, you can also provide the query space as a query hint. The main benefit of this approach is that you can use it with JPA’s Query interface. You no longer need to cast it to one of Hibernate’s proprietary interfaces.