hibernate/hibernate-orm · error · CacheException

Caching was explicitly requested, but no RegionFactory was d

Error message

Caching was explicitly requested, but no RegionFactory was defined and there is not a single registered RegionFactory

What it means

Error "Caching was explicitly requested, but no RegionFactory was defined and there is not a single registered RegionFactory" thrown in hibernate/hibernate-orm.

Source

Thrown at hibernate-core/src/main/java/org/hibernate/cache/internal/RegionFactoryInitiator.java:89

		// We should immediately return NoCachingRegionFactory if either:
		//		1) both are explicitly FALSE
		//		2) USE_SECOND_LEVEL_CACHE is FALSE and USE_QUERY_CACHE is null
		if ( useSecondLevelCache == FALSE ) {
			if ( useQueryCache == null || !useQueryCache ) {
				return NoCachingRegionFactory.INSTANCE;
			}
		}

		final Object setting = configurationValues.get( CACHE_REGION_FACTORY );

		final var selector = registry.requireService( StrategySelector.class );
		final var implementors = selector.getRegisteredStrategyImplementors( RegionFactory.class );

		if ( setting == null && implementors.size() != 1 ) {
			// if either is explicitly defined as TRUE, we need a RegionFactory
			if ( useSecondLevelCache == TRUE || useQueryCache == TRUE ) {
				throw new CacheException( "Caching was explicitly requested, but no RegionFactory was defined and there is not a single registered RegionFactory" );
			}
		}

		final var regionFactory = selector.resolveStrategy(
				RegionFactory.class,
				setting,
				(RegionFactory) null,
				new StrategyCreatorRegionFactoryImpl( properties )
		);

		if ( regionFactory != null ) {
			return regionFactory;
		}

		final var fallback = getFallback( configurationValues, registry );
		if ( fallback != null ) {
			return fallback;
		}

View on GitHub (pinned to fad1729dce)

Solutions

  1. Configure a RegionFactory (hibernate.cache.region.factory_class) and put its provider on the classpath, or remove the cache mappings.

Example fix

Configure a RegionFactory (hibernate.cache.region.factory_class) and put its provider on the classpath, or remove the cache mappings.

When it happens

Trigger: Second-level caching is misconfigured or a cache region/key does not match what Hibernate expects.

Common situations: Enabling @Cacheable entities without setting hibernate.cache.region.factory_class, custom RegionFactory implementations, or unwrapping Cache to provider types.


AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22). Data as JSON: /api/errors/c3911671b8b48895. Report an issue: GitHub.