{"record":{"id":"4da088383d555720","repo":"hibernate/hibernate-orm","slug":"unable-to-locate-persister-event-getentityclass","errorCode":null,"errorMessage":"Unable to locate persister: ${event.getEntityClassName()}","messagePattern":"Unable to locate persister: (.+?)","errorType":"exception","errorClass":"HibernateException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/event/internal/DefaultLoadEventListener.java","lineNumber":56,"sourceCode":"\n/**\n * Defines the default load event listeners used by hibernate for loading entities\n * in response to generated load events.\n *\n * @author Steve Ebersole\n */\npublic class DefaultLoadEventListener implements LoadEventListener {\n\n\t/**\n\t * Handle the given load event.\n\t *\n\t * @param event The load event to be handled.\n\t */\n\t@Override\n\tpublic void onLoad(@Nonnull LoadEvent event, @Nonnull LoadType loadType) {\n\t\tfinal var persister = getPersister( event );\n\t\tif ( persister == null ) {\n\t\t\tthrow new HibernateException( \"Unable to locate persister: \" + event.getEntityClassName() );\n\t\t}\n\t\tcheckId( event, loadType, persister );\n\t\tdoOnLoad( persister, event, loadType );\n\t}\n\n\tprivate void checkId(@Nonnull LoadEvent event, @Nonnull LoadType loadType, @Nonnull EntityPersister persister) {\n\t\tfinal Object id = event.getEntityId();\n\t\tif ( !persister.getIdentifierMapping().getJavaType().isInstance( id )\n\t\t\t\t&& !( id instanceof DelayedPostInsertIdentifier ) ) {\n\t\t\tfinal Class<?> idClass = persister.getIdentifierType().getReturnedClass();\n\t\t\tif ( handleIdType( persister, event, loadType, idClass ) ) {\n\t\t\t\tthrow new TypeMismatchException(\n\t\t\t\t\t\t\"Supplied id had wrong type: entity '\" + persister.getEntityName()\n\t\t\t\t\t\t\t\t+ \"' has id type '\" + idClass\n\t\t\t\t\t\t\t\t+ \"' but supplied id was of type '\" + event.getEntityId().getClass() + \"'\"\n\t\t\t\t);\n\t\t\t}\n\t\t}","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/event/internal/DefaultLoadEventListener.java#L38-L74","documentation":"Error \"Unable to locate persister: ${event.getEntityClassName()}\" thrown in hibernate/hibernate-orm.","triggerScenarios":"Thrown when Hibernate is asked to work with a class/name that is not a mapped managed type in the current SessionFactory.","commonSituations":"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.","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."],"exampleFix":null,"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"}