Reputation: 3263
Supose that there multiple Java applications which share a common entity module (Entity classes + Hibernate XML mappings). Currently, the entities are not enabled for caching (no <cache.../>
elements within the mappings).
Most of the applications are largly concerned with editing single entities an thus it cannot relie on second level cache.
Now, a new application is implemented which
How to configure the cache?
Several observations:
I cannot add <cache.../>
elements to the mappings since this would break the other applications which do not configure such a cache and which are not under my influence:
Second-level cache is not enabled for usage [hibernate.cache.use_second_level_cache | hibernate.cache.use_query_cache]
ehcache.xml
does not help<cache.../>
to the entity mappings, it does not work to disable the cache by setting hibernate.cache.use_second_level_cache=false
although it is said so in http://docs.jboss.org/hibernate/core/3.3/reference/en/html/session-configuration.html, table 3.5Upvotes: 2
Views: 1390
Reputation: 242746
It looks like you can use <class-cache>
elements to configure caching in hibernate.cfg.xml
rather than in entity mappings, see 3.8. XML configuration file.
I guess you can afford creating a custom hibernate.cfg.xml
that would use existing mappings, and if not, there are Configuration.setCacheConcurrencyStrategy()
methods that might help as well.
Upvotes: 1