title: How to add Query Hints to spring data jpa querydsl queries?
body: <p>I'm using Spring Data JPA 1.7.1</p>
  
  <p>I was trying pass query hints (e.g. for Hibernate query caching) to queries when using the querydsl methods of the standard Spring Data repositories, as defined in the <code>QueryDslPredicateExecutor</code> interface, e.g. <code>findOne(Predicate predicate)</code>, <code>findAll(Predicate predicate)</code> etc.</p>
  
  <p>I figured that they can be set by overriding the methods in <code>QueryDslPredicateExecutor</code> (in my repository interface or an intermediate interface) and adding the <code>QueryHints</code> annotation, but since I cannot find this documented anywhere I was wondering if this is the recommended way of doing it.</p>
  
  <p>Here is an example:</p>
  
  <pre><code>public interface MyEntityRepository extends CrudRepository&lt;MyEntity, Integer&gt;, CacheableQueryDslPredicateExecutor&lt;MyEntity&gt; {
  
      @QueryHints(value = {
              @QueryHint(name = "org.hibernate.cacheable", value = "true"),
              @QueryHint(name = "org.hibernate.cacheMode", value = "NORMAL"),
              @QueryHint(name = "org.hibernate.cacheRegion", value = "myCacheRegion")
      })
      Iterable&lt;T&gt; findAll(Predicate predicate);
  
  }
  </code></pre>