hibernate/hibernate-orm · error · HibernateException
Unable to locate persister: ${event.getEntityClassName()}
Error message
Unable to locate persister: ${event.getEntityClassName()} What it means
Error "Unable to locate persister: ${event.getEntityClassName()}" thrown in hibernate/hibernate-orm.
Source
Thrown at hibernate-core/src/main/java/org/hibernate/event/internal/DefaultLoadEventListener.java:56
/**
* Defines the default load event listeners used by hibernate for loading entities
* in response to generated load events.
*
* @author Steve Ebersole
*/
public class DefaultLoadEventListener implements LoadEventListener {
/**
* Handle the given load event.
*
* @param event The load event to be handled.
*/
@Override
public void onLoad(@Nonnull LoadEvent event, @Nonnull LoadType loadType) {
final var persister = getPersister( event );
if ( persister == null ) {
throw new HibernateException( "Unable to locate persister: " + event.getEntityClassName() );
}
checkId( event, loadType, persister );
doOnLoad( persister, event, loadType );
}
private void checkId(@Nonnull LoadEvent event, @Nonnull LoadType loadType, @Nonnull EntityPersister persister) {
final Object id = event.getEntityId();
if ( !persister.getIdentifierMapping().getJavaType().isInstance( id )
&& !( id instanceof DelayedPostInsertIdentifier ) ) {
final Class<?> idClass = persister.getIdentifierType().getReturnedClass();
if ( handleIdType( persister, event, loadType, idClass ) ) {
throw new TypeMismatchException(
"Supplied id had wrong type: entity '" + persister.getEntityName()
+ "' has id type '" + idClass
+ "' but supplied id was of type '" + event.getEntityId().getClass() + "'"
);
}
}View on GitHub (pinned to fad1729dce)
Solutions
- Verify the entity class name passed to load/get is correct and the class is mapped as an entity in this SessionFactory.
- Use the Class object overload (session.get(MyEntity.class, id)) instead of the entity-name string overload to avoid typos.
When it happens
Trigger: Thrown when Hibernate is asked to work with a class/name that is not a mapped managed type in the current SessionFactory.
Common situations: Typical situations: typos in entity names; the entity class not registered in the persistence unit; using a mapped-superclass or unmapped class where an entity is required.
AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22).
Data as JSON: /api/errors/4da088383d555720.
Report an issue: GitHub.