[hibernate-issues] [Hibernate-JIRA] Resolved: (HHH-7102) Misleading error message is shown when no RegionFactory is manually set

Strong Liu (JIRA) noreply at atlassian.com
Thu Feb 23 03:57:48 EST 2012


     [ https://hibernate.onjira.com/browse/HHH-7102?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Strong Liu resolved HHH-7102.
-----------------------------

       Resolution: Fixed
    Fix Version/s: 4.1.1

> 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
>             Fix For: 4.1.1
>
>         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: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list