[hibernate-dev] Auto-registering the cacheable entities and collections
Steve Ebersole
steve at hibernate.org
Wed May 30 11:50:38 EDT 2018
That is unintended, likely from the L2C service changes. Yes we should
change that to match the old behavior.
On Wed, May 30, 2018 at 9:43 AM Vlad Mihalcea <mihalcea.vlad at gmail.com>
wrote:
> Hi,
>
> While upgrading my Hibernate testing repository to 5.3, I realized that we
> no longer auto-register the 2nd-level cache for entities and the
> collections even if those are annotated with the Hibernate @Cache
> annotation.
>
> I noticed that the Hibernate tests have been modified and we require to
> register those manually:
>
> for ( Map.Entry<Class, String> entry : getCachedClasses().entrySet() ) {
> config.put( AvailableSettings.CLASS_CACHE_PREFIX + "." +
> entry.getKey().getName(), entry.getValue() );
> }
> for ( Map.Entry<String, String> entry : getCachedCollections().entrySet() )
> {
> config.put( AvailableSettings.COLLECTION_CACHE_PREFIX + "." +
> entry.getKey(), entry.getValue() );
> }
>
> Now, if I don't do that, I get the following exception:
>
> Caused by: org.hibernate.cache.CacheException: On-the-fly creation of
> JCache Cache objects is not supported
>
> [com.vladmihalcea.book.hpjp.hibernate.cache.query.QueryCacheTest$Post.comments]
> at
>
> org.hibernate.cache.ehcache.internal.EhcacheRegionFactory.createCache(EhcacheRegionFactory.java:106)
> at
>
> org.hibernate.cache.ehcache.internal.EhcacheRegionFactory.getOrCreateCache(EhcacheRegionFactory.java:100)
> at
>
> org.hibernate.cache.ehcache.internal.EhcacheRegionFactory.createDomainDataStorageAccess(EhcacheRegionFactory.java:71)
> at
>
> org.hibernate.cache.spi.support.RegionFactoryTemplate.buildDomainDataRegion(RegionFactoryTemplate.java:31)
> at
> org.hibernate.cache.internal.EnabledCaching.prime(EnabledCaching.java:108)
> at
>
> org.hibernate.metamodel.internal.MetamodelImpl.primeSecondLevelCacheRegions(MetamodelImpl.java:284)
> at
>
> org.hibernate.metamodel.internal.MetamodelImpl.initialize(MetamodelImpl.java:116)
> at
>
> org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:295)
> at
>
> org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:467)
> at
>
> org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:939)
>
>
> However, I don't even use JCache. I use "ehcache" instead.
>
> properties.put("hibernate.cache.region.factory_class", "ehcache");
>
> Was a JCache requirement?
>
> Can we auto-register the entities and collections for other cache
> providers?
>
> I'm worried about all those applications trying to upgrade to 5.3. Imagine
> if they have hundreds of entities and collections. People will surely start
> complaining if we force them to do that manually during bootstrap. More,
> I'm not sure how they can do when they just bootstrap via a JPA
> persistence.xml configuration file.
>
> Vlad
> _______________________________________________
> hibernate-dev mailing list
> hibernate-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/hibernate-dev
>
More information about the hibernate-dev
mailing list