Кэширование аннотации на интерфейсные методы - PullRequest
0 голосов
/ 11 февраля 2019

Учитывая, что у меня есть репозиторий Spring Data, и я помещаю Cacheable аннотацию на findAll метод:

@Repository
@CacheConfig(cacheNames = TEMPLATE_CACHE)
public interface TemplateRepository extends JpaRepository<Template, Long> {
    @Override
    @Cacheable
    List<Template> findAll();
}

Intellij IDEA показывает предупреждение:

Spring Team recommends that you only annotate concrete classes (and methods of concrete classes) with the @Cache* annotation, as opposed to annotating interfaces. 
You certainly can place the @Cache* annotation on an interface (or an interface method), but this works only as you would expect it to if you are using interface-based proxies. 
The fact that Java annotations are not inherited from interfaces means that if you are using class-based proxies (proxy-target-class="true") or the weaving-based aspect (mode="aspectj"),
then the caching settings are not recognized by the proxying and weaving infrastructure, and the object will not be wrapped in a caching proxy, which would be decidedly bad.

Isэто действительно так плохо?

Что может произойти с практической точки зрения?

Куда мне поместить эту аннотацию, если я хочу назвать findAll, например, Controller mapping?

Как Spring Data справляется с этим?Кажется, у меня все хорошо.

...