{"record":{"id":"c3911671b8b48895","repo":"hibernate/hibernate-orm","slug":"caching-was-explicitly-requested-but-no-regionfac","errorCode":null,"errorMessage":"Caching was explicitly requested, but no RegionFactory was defined and there is not a single registered RegionFactory","messagePattern":"Caching was explicitly requested, but no RegionFactory was defined and there is not a single registered RegionFactory","errorType":"exception","errorClass":"CacheException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/cache/internal/RegionFactoryInitiator.java","lineNumber":89,"sourceCode":"\n\t\t// We should immediately return NoCachingRegionFactory if either:\n\t\t//\t\t1) both are explicitly FALSE\n\t\t//\t\t2) USE_SECOND_LEVEL_CACHE is FALSE and USE_QUERY_CACHE is null\n\t\tif ( useSecondLevelCache == FALSE ) {\n\t\t\tif ( useQueryCache == null || !useQueryCache ) {\n\t\t\t\treturn NoCachingRegionFactory.INSTANCE;\n\t\t\t}\n\t\t}\n\n\t\tfinal Object setting = configurationValues.get( CACHE_REGION_FACTORY );\n\n\t\tfinal var selector = registry.requireService( StrategySelector.class );\n\t\tfinal var implementors = selector.getRegisteredStrategyImplementors( RegionFactory.class );\n\n\t\tif ( setting == null && implementors.size() != 1 ) {\n\t\t\t// if either is explicitly defined as TRUE, we need a RegionFactory\n\t\t\tif ( useSecondLevelCache == TRUE || useQueryCache == TRUE ) {\n\t\t\t\tthrow new CacheException( \"Caching was explicitly requested, but no RegionFactory was defined and there is not a single registered RegionFactory\" );\n\t\t\t}\n\t\t}\n\n\t\tfinal var regionFactory = selector.resolveStrategy(\n\t\t\t\tRegionFactory.class,\n\t\t\t\tsetting,\n\t\t\t\t(RegionFactory) null,\n\t\t\t\tnew StrategyCreatorRegionFactoryImpl( properties )\n\t\t);\n\n\t\tif ( regionFactory != null ) {\n\t\t\treturn regionFactory;\n\t\t}\n\n\t\tfinal var fallback = getFallback( configurationValues, registry );\n\t\tif ( fallback != null ) {\n\t\t\treturn fallback;\n\t\t}","sourceCodeStart":71,"sourceCodeEnd":107,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/cache/internal/RegionFactoryInitiator.java#L71-L107","documentation":"Error \"Caching was explicitly requested, but no RegionFactory was defined and there is not a single registered RegionFactory\" thrown in hibernate/hibernate-orm.","triggerScenarios":"Second-level caching is misconfigured or a cache region/key does not match what Hibernate expects.","commonSituations":"Enabling @Cacheable entities without setting hibernate.cache.region.factory_class, custom RegionFactory implementations, or unwrapping Cache to provider types.","solutions":["Configure a RegionFactory (hibernate.cache.region.factory_class) and put its provider on the classpath, or remove the cache mappings."],"exampleFix":"Configure a RegionFactory (hibernate.cache.region.factory_class) and put its provider on the classpath, or remove the cache mappings.","handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}