title: Condition on cacheable annotation on private property of Object
body: <p>I have a use case in which I want to be able to cache the result of a method based on the property of a object. The property is private but exposes a public getter. (This can be changed, but i would not want to do that)</p>
  
  <pre><code>@Cacheable(cacheNames = "detailedData", key = "#id", condition = "#currentPackage.getSellingPrice() &gt; -1")
  public Map&lt;String, Object&gt; getDetailedTestData(int id,PackageEntity currentPackage) {
  /**
  some code
  */
  }
  </code></pre>
  
  <p><code>PackageEntity</code> class is</p>
  
  <pre><code>public class PackageEntity {
  
      private int sellingPrice;
  
      public int getSellingPrice() {
          return sellingPrice;
      }
  
      public void setSellingPrice(int sellingPrice) {
          this.sellingPrice = sellingPrice;
      }
    /**
    some other fields and their getter/setter
    */
  }
  </code></pre>
  
  <p>Spring doc for conditional caching specifies how to use condition. However, this cahcing does not works as indicated by condition. It is simply caching all packages irrespective of selling price. 
  I am unable to understand what am I doing wrong. Neither there are suitable examples that I can refer for this.</p>
  
  <p>Any help appreciated. Thanks</p>
  
  <p><a href="http://docs.spring.io/spring/docs/current/spring-framework-reference/html/cache.html#cache-annotations-cacheable-condition" rel="nofollow">http://docs.spring.io/spring/docs/current/spring-framework-reference/html/cache.html#cache-annotations-cacheable-condition</a></p>