0

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.

user503285
  • 125
  • 3
  • 14
  • 1
    A couple of blind guesses: you are passing a method name (a String) where a Method is expected; you are calling a non-static method on a class. – Michał Politowski Jan 22 '13 at 15:53
  • actually I have used the spel context to pass a method (i.e. #root.method.name)..but its not happening the way I am expecting. – user503285 Jan 22 '13 at 16:13
  • Maybe you could have a look at [this question](http://stackoverflow.com/q/14259165/1225328), you could find some interesting stuff for the problem your facing. – sp00m Jan 22 '13 at 16:27
  • the above solution looks good..but am trying to access the method in a key generator class by using the following code "T(com.ernst.transactionsAPI.IndexKeyGenerator).generate(#root.target, #root.method.name, #root.args[0])") #root.method.name have to reflect method with object Method but its passing string object. – user503285 Jan 23 '13 at 08:18

1 Answers1

1

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.

user503285
  • 125
  • 3
  • 14