Auto-register entity and collection caches based on the Hibernate @Cache annotation (XML mapping) settings

Description

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:

Now, if I don't do that, I get the following exception:

However, I don't even use JCache. I use "ehcache" instead.

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.

Activity

Show:

Guenther Demetz July 6, 2018 at 12:05 PM

Thanks Yoann, issue solved.

Apologies again for my initial harsh tone.
I ran in part 5.3.1 code because I forgot that the hibernate-release-5.3.2.Final.zip does not contain hibernate-ehcache.jar which I had to download separately. With that and the config-property corrected all works fine as expected

Yoann Rodière July 6, 2018 at 11:02 AM

<property name="hibernate.hibernate.cache.ehcache.missing_cache_strategy" value="create"/>
did not help (I'm using ehcache 2.10.1)

You wrote "hibernate." twice. Please try again with hibernate.cache.ehcache.missing_cache_strategy.

Guenther Demetz July 6, 2018 at 10:27 AM

I was trying the latest release, 5.3.2.Final but looked by error on the source of 5.3.1, sorry for that and apologies.
But configuring:
<property name="hibernate.hibernate.cache.ehcache.missing_cache_strategy" value="create"/>
did not help (I'm using ehcache 2.10.1)

Vlad Mihalcea July 6, 2018 at 7:05 AM

I tested it in this branch of my high-performance-java-persistence GitHub repository and the issue was solved.

The only issue left related to 2nd-level cache configs is HHH-12771. I'll provide a test case next week for that.

Yoann Rodière July 6, 2018 at 6:52 AM

You solved it for users using JCache, giving the possibility to define missing_cache_strategy "create",

but the issue creator clearly stated that he is using ehcache directly not jcache.

No, we (at least tried) to solve it for both: https://github.com/hibernate/hibernate-orm/commit/c52ff4d06c95302fbf66b6c0dc2ac79f81819b81#diff-59b8d24e6179e8fa85722b3e4641de0cR108

The EhcacheRegionFactory class is still affect by this issue as it still does not allow on-the-fly creation (see line 106).

Did you try the latest release, 5.3.2.Final, released yesterday? Or are you saying that based on an older version of the code?

Overmore there it says "On-the-fly creation of JCache Cache objects is not supported .."

instead of "On-the-fly creation of EHCache Cache objects is not supported .."

This was fixed too: https://github.com/hibernate/hibernate-orm/commit/c52ff4d06c95302fbf66b6c0dc2ac79f81819b81#diff-59b8d24e6179e8fa85722b3e4641de0cR117

Fixed

Details

Assignee

Reporter

Components

Fix versions

Affects versions

Priority

Created May 30, 2018 at 4:20 PM
Updated July 6, 2018 at 12:05 PM
Resolved July 4, 2018 at 8:05 AM