Вопрос

I am trying to access a custom key generator to generate key for caching by using a method in cache abstraction doc, but till now I have not found any solution...here I am giving my code

@Cacheable(value = "itemsCache", key ="T(com.ernst.transactionsAPI.IndexKeyGenerator).generate(#root.target, #root.method.name, #root.args[0])")
public List<FilialenImpl> getOutletByCustomSearchCache(SearchParametersImpl searchParameters);

and I am getting following error:

org.springframework.expression.spel.SpelEvaluationException: EL1004E:(pos 47): Method call: Method generate(com.ernst.transactionsImpl.filialen.FilialenServiceBean,java.lang.String,com.ernst.persistenceImpl.impl.SearchParametersImpl) cannot be found on com.ernst.transactionsAPI.IndexKeyGenerator type

its not reflecting the method name but its passing the method type..can any one please how to solve this problem.

method in indexkeygenerator looks like

public Object generate(Object target, Method method, Object... params) {
 ...}

Thanks in Advance,

Regards, Rajasekhar.

Это было полезно?

Решение

I have written a static method generateKey in IndexKeyGenerator class and called it directly as shown in following code..then the custom cache for individual caching works just perfect

@Cacheable(value = "itemsCache", key ="T(com.ernst.transactionsAPI.IndexKeyGenerator).generateKey(#root.target, #root.method, #root.args[0])") public List<FilialenImpl> getOutletByCustomSearchCache(SearchParametersImpl searchParameters);

don't forget to override the SearchParameters class.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top