title: Spring with ehcache not caching objects
body: <p>I am using spring 4.1 with ehcache. I am able to cache string values with an integer key but whenever I try to cache an object, it fails without any error. The model (POJO) I am saving in cache does implement hashcode, equals and tostring functions.</p>
  
  <p>ehcache configuration as below</p>
  
  <pre><code>&lt;diskStore path="E:/ymserviceslog" /&gt;
  
  &lt;defaultCache maxElementsInMemory="50" eternal="false"
  overflowToDisk="false" memoryStoreEvictionPolicy="LFU" /&gt;
  
  &lt;cache name="test" maxElementsInMemory="1000" eternal="false"
  overflowToDisk="true" memoryStoreEvictionPolicy="LRU"
  timeToLiveSeconds="3000" diskPersistent="true" /&gt;
  </code></pre>
  
  <p>Spring configuration as below</p>
  
  <pre><code>&lt;cache:annotation-driven proxy-target-class="true"/&gt;
  &lt;context:component-scan base-package="com.ashitosh.ym.dao" /&gt;
  
  &lt;bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheCacheManager"&gt;
              &lt;property name="cacheManager" ref="ehcache" /&gt;
  &lt;/bean&gt;
  
  &lt;bean id="ehcache" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean"&gt;
      &lt;property name="configLocation" value="classpath:ehcache.xml" /&gt;
      &lt;property name="shared" value="true"/&gt;
  &lt;/bean&gt;
  
  &lt;bean id="cachedao" class="com.ashitosh.ym.dao.Cache"/&gt;
  </code></pre>
  
  <p>My class and method to be cached</p>
  
  <pre><code>public class Cache implements Icache {
  
      @Override
      @Cacheable(value = "test", key="#id")
      public Party getPerson(int id) {
          Party party = new Party("data",1);
          return party;
      }
  
  }
  </code></pre>
  
  <p>If I replace the return value of the method getPerson from Party object to String, it works.
  Any ideas?</p>