{"record":{"id":"d9dbbb9333d8636c","repo":"hibernate/hibernate-orm","slug":"hibernate-cannot-unwrap-cache-as-type-getname","errorCode":null,"errorMessage":"Hibernate cannot unwrap Cache as '{type.getName()}'","messagePattern":"Hibernate cannot unwrap Cache as '(.+?)'","errorType":"exception","errorClass":"PersistenceException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/cache/internal/DisabledCaching.java","lineNumber":243,"sourceCode":"\n\t@Override\n\tpublic void evict(@Nonnull Class<?> cls, @Nonnull Object primaryKey) {\n\t\t// nothing to do\n\t}\n\n\t@Override\n\tpublic void evict(@Nonnull Class<?> cls) {\n\t\t// nothing to do\n\t}\n\n\t@Override\n\t@Nonnull\n\tpublic <T> T unwrap(@Nonnull Class<T> type) {\n\t\tif ( type.isAssignableFrom( DisabledCaching.class ) ) {\n\t\t\treturn type.cast( this );\n\t\t}\n\t\telse {\n\t\t\tthrow new PersistenceException( \"Hibernate cannot unwrap Cache as '\" + type.getName() + \"'\" );\n\t\t}\n\t}\n}\n","sourceCodeStart":225,"sourceCodeEnd":247,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/cache/internal/DisabledCaching.java#L225-L247","documentation":"Error \"Hibernate cannot unwrap Cache as '{type.getName()}'\" 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":["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."],"exampleFix":"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.","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"}