phury
phury

Reputation: 2203

hibernate `cache usage` parameter programmatically

I'm currently configuring hibernate to use ehcache and provide a CacheManager programmatically. We do not use hibernate.xml nor ehcache.xml as we have our own configuration service to provide such informataion.

Now I'm facing an issue: where must the configuration cache usage be defined programmatically?

I'd like to activate it when I create the CacheConfiguration if it is possible but I do not find a method that allows setting the property.

Thanks in advance

Upvotes: 1

Views: 834

Answers (1)

Anantha Sharma
Anantha Sharma

Reputation: 10108

this forum post can help here.

all you need to do afer writing the code by "F.Degenaar" is, while creating the session factory, create a java.util.Properties object add the property (key) hibernate.cache.provider_class and value the fully qualified class name with the EhCacheProvider.

--edit

you can add the objects to cache manually, as far as programatically settting something to be cached or not is concerned, its gonna be quite difficult as the annotations are at compile time, Id recommend you to use the annotation and programatically cache/avoid caching queries and results.

Upvotes: 1

Related Questions