Hi hjo,
Quote:
By default, entities are not part of the second-level cache, and their use is not recommended.
I think this sentence is expressed unhappily.
What's this sentence intends to say in my opinion is:
It it not recommended to set entity caching javax.persistence.sharedCache.mode to ALL or to DISABLE_SELECTIVE
You should indeed use caching javax.persistence.sharedCache.ENABLE_SELECTIVE (=default)
and explicitly mark determinate entity classes as cachable. This is the default and recommended value.
There's also the note:
Quote:
When possible, define the cache concurrency strategy per entity rather than globally. Use the @org.hibernate.annotations.Cache annotation.
I guess the motivations are:
-enabling sharedCache.mode to ALL may cause the 2L-Cache requiring to much ressources (or the 2L-Cache becomes rather ineffective due to many evictions and re-puts)
-with selective enabling you can use concurrency strategies which are more appropriate for the given classes.
For example is the content of a entity class is static, you should use the read-only concurrency strategy for it.
I use Hibernate since more than a year sucessfully with 2L-cache caching entities as well as collections and queries.
So far I never encountered problems and the performance gain was clearly measureable.