The following are some programming tips in relation to the different caching levels in Hibernate:
- Make sure to use the same version of hibernate-ehcache as the version of Hibernate.
- Since Hibernate caches all of the objects into the session first level cache, when running bulk queries or batch updates, it's necessary to clear the cache at certain intervals to avoid memory issues.
- When caching an entity using the second level cache, collections inside of the entity are not cached by default. In order to cache the collections, annotate the collections within the entity with @Cacheable and @org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_WRITE). Each collection is stored in a separate region in the second level ...