0
votes

I'm using EHCache with Hibernate to cache my DB query results. I'm using google annotations(com.googlecode.ehcache.annotations.Cacheable) to make DAO methods cacheable.

My problem is that, one of the argument in the method is a java.util.Map and I have no clue how to cache it?

Sample Code :

import com.googlecode.ehcache.annotations.Cacheable;
import com.googlecode.ehcache.annotations.KeyGenerator;
import com.googlecode.ehcache.annotations.PartialCacheKey;
import com.googlecode.ehcache.annotations.Property;

Here is the sample method

@Cacheable(cacheName = "ehcahe", keyGenerator = @KeyGenerator(name = "HashCodeCacheKeyGenerator", properties = @Property(name = "includeMethod", value = "false")))
public Object get( @PartialCacheKey Map map ) {
 //do something
}

Any help?

1

1 Answers

1
votes

You can implement your own CacheKeyGenerator , See FAQ, Question 7