hibernate/hibernate-orm · error · PersistenceException
Hibernate cannot unwrap Cache as '{type.getName()}'
Error message
Hibernate cannot unwrap Cache as '{type.getName()}' What it means
Error "Hibernate cannot unwrap Cache as '{type.getName()}'" thrown in hibernate/hibernate-orm.
Source
Thrown at hibernate-core/src/main/java/org/hibernate/cache/internal/DisabledCaching.java:243
@Override
public void evict(@Nonnull Class<?> cls, @Nonnull Object primaryKey) {
// nothing to do
}
@Override
public void evict(@Nonnull Class<?> cls) {
// nothing to do
}
@Override
@Nonnull
public <T> T unwrap(@Nonnull Class<T> type) {
if ( type.isAssignableFrom( DisabledCaching.class ) ) {
return type.cast( this );
}
else {
throw new PersistenceException( "Hibernate cannot unwrap Cache as '" + type.getName() + "'" );
}
}
}
View on GitHub (pinned to fad1729dce)
Solutions
- Unwrap the Cache to a type it actually implements (e.g. the provider's region type), or check that the expected cache provider is configured.
Example fix
Unwrap the Cache to a type it actually implements (e.g. the provider's region type), or check that the expected cache provider is configured.
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/d9dbbb9333d8636c.
Report an issue: GitHub.