How to add QueryHints on Default Spring Data JPA Methods?

后端 未结 2 1868
误落风尘
误落风尘 2021-02-04 11:58

I am able to use Query Cache with Spring Data JPA for my custom query methods like below.

public interface CountryRepository extends JpaRepository

        
相关标签:
2条回答
  • 2021-02-04 12:19

    Originally, there was no support for query hint annotations in default CRUD methods, but apparently it hass been fixed for version 1.6M1:

    https://jira.spring.io/browse/DATAJPA-173

    0 讨论(0)
  • 2021-02-04 12:28

    findAll(), findOne() etc. are not Query(s). Any caching specifications on the entity take effect in these methods.

    For example,

    @Cacheable
    @Entity
    public class User {
    
    }
    
    0 讨论(0)
提交回复
热议问题