title: Caffeine cache does not prevent from database queries
body: <p>I've implemented basic set up of Caffeine cache in Spring Boot app. Below you will find configuration and service method annotated with <code>@Cachable</code>. Unfortunately every call for this method generates database query and new input to cache (with same key):</p>
  <p><a href="https://i.stack.imgur.com/sOd0L.png" rel="nofollow noreferrer">Debug result with cache content</a></p>
  <pre><code>    @Cacheable(cacheNames = {&quot;pic&quot;})
      public PictureModel loadPictureById(String id) {
          var loadedInstance = pictureRepo.findById(id).orElseThrow(() -&gt; new CustomNotFoundException(PictureModel.class));
          loadedInstance.setBody(pictureCompressor.decompressBytes(loadedInstance.getBody()));
          return loadedInstance;
      }
  </code></pre>
  <p>Configuration:</p>
  <pre><code>@EnableCaching
  @Configuration
  public class CaffeineConfig {
      @Bean
      public CacheManager cacheManager() {
          CaffeineCacheManager cacheManager = new CaffeineCacheManager(&quot;pic&quot;);
          cacheManager.setCaffeine(caffeineCacheBuilder());
          return cacheManager;
      }
  
      Caffeine &lt;Object, Object&gt; caffeineCacheBuilder() {
          return Caffeine.newBuilder()
                  .initialCapacity(100)
                  .maximumSize(500)
                  .expireAfterAccess(10, TimeUnit.MINUTES)
                  .weakKeys()
                  .recordStats();
      }
  }
  </code></pre>
  <p>Database queries after three hits:</p>
  <pre><code>Hibernate: 
      select
          picturemod0_.id as id1_10_0_,
          picturemod0_.account_id as account_5_10_0_,
          picturemod0_.body as body2_10_0_,
          picturemod0_.name as name3_10_0_,
          picturemod0_.public_platform_id as public_p6_10_0_,
          picturemod0_.service_type_id as service_7_10_0_,
          picturemod0_.type as type4_10_0_ 
      from
          image picturemod0_ 
      where
          picturemod0_.id=?
  Hibernate: 
      select
          picturemod0_.id as id1_10_0_,
          picturemod0_.account_id as account_5_10_0_,
          picturemod0_.body as body2_10_0_,
          picturemod0_.name as name3_10_0_,
          picturemod0_.public_platform_id as public_p6_10_0_,
          picturemod0_.service_type_id as service_7_10_0_,
          picturemod0_.type as type4_10_0_ 
      from
          image picturemod0_ 
      where
          picturemod0_.id=?
  Hibernate: 
      select
          picturemod0_.id as id1_10_0_,
          picturemod0_.account_id as account_5_10_0_,
          picturemod0_.body as body2_10_0_,
          picturemod0_.name as name3_10_0_,
          picturemod0_.public_platform_id as public_p6_10_0_,
          picturemod0_.service_type_id as service_7_10_0_,
          picturemod0_.type as type4_10_0_ 
      from
          image picturemod0_ 
      where
          picturemod0_.id=?
  </code></pre>
  <p>I would like to achieve one database query and other hits to be served by cache.</p>