title: How to clear EhCache Jhipster
body: <p>I'm trying to clear Hibernate cache, but I can't get the Ehcache context to clear it. 
  Thanks in advance.</p>
  
  <p><strong>CacheConfiguration.java</strong>, </p>
  
  <pre><code>public class CacheConfiguration {
  
      private final javax.cache.configuration.Configuration&lt;Object, Object&gt; jcacheConfiguration;
  
      public CacheConfiguration(JHipsterProperties jHipsterProperties) {
          JHipsterProperties.Cache.Ehcache ehcache = jHipsterProperties.getCache().getEhcache();
  
          jcacheConfiguration = Eh107Configuration.fromEhcacheCacheConfiguration(
                  CacheConfigurationBuilder.newCacheConfigurationBuilder(Object.class, Object.class,
                          ResourcePoolsBuilder.heap(ehcache.getMaxEntries()))
                          .withExpiry(ExpiryPolicyBuilder.timeToLiveExpiration(Duration.ofSeconds(ehcache.getTimeToLiveSeconds())))
                          .build());
      }
  
      @Bean
      public JCacheManagerCustomizer cacheManagerCustomizer() {
          return cm -&gt; {
              createCache(cm, co.interedes.repository.UserRepository.USERS_BY_LOGIN_CACHE);
              createCache(cm, co.interedes.repository.UserRepository.USERS_BY_EMAIL_CACHE);
              cm.createCache(co.interedes.domain.EntityAuditEvent.class.getName(), jcacheConfiguration);
              // jhipster-needle-ehcache-add-entry
          };
      }
  
   private void createCache(javax.cache.CacheManager cm, String cacheName) {
          javax.cache.Cache&lt;Object, Object&gt; cache = cm.getCache(cacheName);
          if (cache != null) {
              cm.destroyCache(cacheName);
          }
          cm.createCache(cacheName, jcacheConfiguration);
      }
  }
  </code></pre>
  
  <p>In this post <a href="https://www.journaldev.com/2969/hibernate-caching-first-level-cache" rel="nofollow noreferrer">https://www.journaldev.com/2969/hibernate-caching-first-level-cache</a> clear the first level, but in Jhipster the config its different</p>