Skip to content

Commit 84f3821

Browse files
committed
HHH-7102 Misleading error message is shown when no RegionFactory is manually set
1 parent 13f4c83 commit 84f3821

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

hibernate-core/src/main/java/org/hibernate/cache/NoCachingEnabledException.java renamed to hibernate-core/src/main/java/org/hibernate/cache/NoCacheRegionFactoryAvailableException.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,16 @@
2626
import org.hibernate.cfg.Environment;
2727

2828
/**
29-
* Implementation of NoCachingEnabledException.
29+
* Implementation of NoCacheRegionFactoryAvailableException.
3030
*
3131
* @author Steve Ebersole
3232
*/
33-
public class NoCachingEnabledException extends CacheException {
34-
private static final String MSG =
35-
"Second-level cache is not enabled for usage [" +
36-
Environment.USE_SECOND_LEVEL_CACHE +
37-
" | " + Environment.USE_QUERY_CACHE + "]";
38-
39-
public NoCachingEnabledException() {
33+
public class NoCacheRegionFactoryAvailableException extends CacheException {
34+
private static final String MSG = "Second-level cache is used in the application, but property "
35+
+ Environment.CACHE_REGION_FACTORY + "is not gaven, please either disable second level cache" +
36+
" or set correct region factory class name to property "+Environment.CACHE_REGION_FACTORY+
37+
" (and make sure the second level cache provider, hibernate-infinispan, for example, available in the classpath).";
38+
public NoCacheRegionFactoryAvailableException() {
4039
super( MSG );
4140
}
4241
}

hibernate-core/src/main/java/org/hibernate/cache/internal/NoCachingRegionFactory.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
import java.util.Properties;
2727

2828
import org.hibernate.cache.CacheException;
29-
import org.hibernate.cache.NoCachingEnabledException;
29+
import org.hibernate.cache.NoCacheRegionFactoryAvailableException;
3030
import org.hibernate.cache.spi.CacheDataDescription;
3131
import org.hibernate.cache.spi.CollectionRegion;
3232
import org.hibernate.cache.spi.EntityRegion;
@@ -66,24 +66,24 @@ public long nextTimestamp() {
6666

6767
public EntityRegion buildEntityRegion(String regionName, Properties properties, CacheDataDescription metadata)
6868
throws CacheException {
69-
throw new NoCachingEnabledException();
69+
throw new NoCacheRegionFactoryAvailableException();
7070
}
7171

7272
public NaturalIdRegion buildNaturalIdRegion(String regionName, Properties properties, CacheDataDescription metadata)
7373
throws CacheException {
74-
throw new NoCachingEnabledException();
74+
throw new NoCacheRegionFactoryAvailableException();
7575
}
7676

7777
public CollectionRegion buildCollectionRegion(String regionName, Properties properties, CacheDataDescription metadata)
7878
throws CacheException {
79-
throw new NoCachingEnabledException();
79+
throw new NoCacheRegionFactoryAvailableException();
8080
}
8181

8282
public QueryResultsRegion buildQueryResultsRegion(String regionName, Properties properties) throws CacheException {
83-
throw new NoCachingEnabledException();
83+
throw new NoCacheRegionFactoryAvailableException();
8484
}
8585

8686
public TimestampsRegion buildTimestampsRegion(String regionName, Properties properties) throws CacheException {
87-
throw new NoCachingEnabledException();
87+
throw new NoCacheRegionFactoryAvailableException();
8888
}
8989
}

0 commit comments

Comments
 (0)