Raushan
Raushan

Reputation: 337

SingletonEhCacheRegionFactory not available with Hibernate 6.1.7

We are using hibernate 5.2.5, where we were overriding start method of org.hibernate.cache.ehcache.SingletonEhCacheRegionFactory todo some init actions. This class we configure in persistence.xml for key "hibernate.cache.region.factory_class"

public class AppSingletonEhCacheRegionFactory extends SingletonEhCacheRegionFactory {

    @Override
    public void start(SessionFactoryOptions settings, Properties properties) throws CacheException {
        //init_actions
        super.start(settings, properties);
    }
}

Now we are upgrading to 6.1.7.FINAL

In docs, EHcache is not mentioned in hibernate 6.1.7 https://docs.jboss.org/hibernate/orm/6.1/userguide/html_single/Hibernate_User_Guide.html#caching-config-provider

persistence.xml

 <persistence-unit name="db" transaction-type="JTA">
        <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
        <jta-data-source>app.jdbc.APPDS</jta-data-source>
        <properties>
            <property name="jboss.as.jpa.providerModule" value="org.hibernate:main"/>
            <property name="hibernate.cache.region.factory_class"
                      value="com.app.AppSingletonEhCacheRegionFactory"/>
            <property name="hibernate.connection.release_mode" value="after_transaction"/>
            <property name="hibernate.cache.use_second_level_cache" value="true"/>
            <property name="hibernate.cache.use_query_cache" value="true"/>
            <property name="hibernate.jdbc.batch_size" value="30"/>
            <property name="net.sf.ehcache.cacheManagerName" value="app-cache"/>
            <property name="hibernate.integration.envers.enabled" value="false"/>
            <property name="hibernate.cache.region_prefix" value=""/>
        </properties>
    </persistence-unit>

Upvotes: 0

Views: 741

Answers (2)

Monish Sen
Monish Sen

Reputation: 1888

Below configuration snippets for JCache configuration

Programmatic

jpaProperties.setProperty("hibernate.cache.region.factory_class", "jcache");

or

jpaProperties.setProperty("hibernate.cache.region.factory_class", "org.hibernate.cache.jcache.JCacheRegionFactory");

XML

<property name="hibernate.cache.region.factory_class" value="jcache"/>

Documentation https://docs.jboss.org/hibernate/orm/6.1/userguide/html_single/Hibernate_User_Guide.html#caching-provider-jcache

Upvotes: 0

Christian Beikov
Christian Beikov

Reputation: 16430

EHcache can be configure by using the JCache integration. Take a look into the JCache integration tests to see how we test this.

Upvotes: 0

Related Questions