]
Strong Liu reassigned HHH-7102:
-------------------------------
Assignee: Strong Liu
Misleading error message is shown when no RegionFactory is manually
set
-----------------------------------------------------------------------
Key: HHH-7102
URL:
https://hibernate.onjira.com/browse/HHH-7102
Project: Hibernate ORM
Issue Type: Bug
Components: core
Affects Versions: 4.1.0
Environment: hibernate-jpa-2.0-api:1.0.1.Final; hibernate-core:4.1.0.Final;
hibernate-entitymanager:4.1.0.Final
Reporter: Michael Nascimento Santos
Assignee: Strong Liu
Labels: cache, hibernate, jpa2
Attachments: misleadingmessagewithnoregionfactoryset.zip
When an entity is marked as @Cacheable (and have @Cache on it, to work around HHH-7101),
an exception will be thrown when calling Persistence.createEntityManagerFactory(String)
informing the user that cache is not enabled and either
hibernate.cache.use_second_level_cache or hibernate.cache.use_query_cache need to be set.
Although this is obviously very helpful, the exception will continue to be thrown with
the same text even once both properties are set to true:
Caused by: org.hibernate.cache.NoCachingEnabledException: Second-level cache is not
enabled for usage [hibernate.cache.use_second_level_cache |
hibernate.cache.use_query_cache]
at
org.hibernate.cache.internal.NoCachingRegionFactory.buildEntityRegion(NoCachingRegionFactory.java:69)
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:347)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1740)
at
org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:88)
at
org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:904)
... 11 more
At this point, the problem is Hibernate is using NoCachingRegionFactory instead of a
valid one, but the message is completely deceiving and wastes user time. Instead, a clear
message showing that a RegionFactory other than NoCachingRegionFactory should be set using
hibernate.cache.region.factory_class should be produced instead.
Attached is a Maven-powered sample with Derby that can be executed with exec:java .
--
This message is automatically generated by JIRA.
For more information on JIRA, see: