hibernate/hibernate-orm · error · HibernateException
Illegal attempt to build cache entry for non-cached entity
Error message
Illegal attempt to build cache entry for non-cached entity
What it means
Error "Illegal attempt to build cache entry for non-cached entity" thrown in hibernate/hibernate-orm.
Source
Thrown at hibernate-core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java:5342
}
private static class NoopCacheEntryHelper implements CacheEntryHelper {
public static final NoopCacheEntryHelper INSTANCE = new NoopCacheEntryHelper();
@Override
@Nonnull
public CacheEntryStructure getCacheEntryStructure() {
return UnstructuredCacheEntry.INSTANCE;
}
@Override
@Nonnull
public CacheEntry buildCacheEntry(
@Nonnull Object entity,
@Nonnull Object[] state,
@Nullable Object version,
@Nonnull SharedSessionContractImplementor session) {
throw new HibernateException( "Illegal attempt to build cache entry for non-cached entity" );
}
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// org.hibernate.metamodel.mapping.EntityMappingType
@Override
public void forEachAttributeMapping(Consumer<? super AttributeMapping> action) {
this.attributeMappings.forEach( action );
}
@Override
public void forEachAttributeMapping(IndexedConsumer<? super AttributeMapping> consumer) {
attributeMappings.indexedForEach( consumer );
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~View on GitHub (pinned to fad1729dce)
Solutions
- Only build cache entries for entities whose persister has cache access; check cache configuration (@Cacheable / region) for the entity.
When it happens
Trigger: Thrown when code attempts to build a second-level cache entry for an entity whose persister is not cached.
Common situations: See trigger scenarios.
AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22).
Data as JSON: /api/errors/7113a3f4f9a03dc9.
Report an issue: GitHub.