{"record":{"id":"30b1eaf5a8a9ab8b","repo":"hibernate/hibernate-orm","slug":"not-an-entity-type-or-supertype-of-an-entity-type","errorCode":null,"errorMessage":"Not an entity type or supertype of an entity type: {}","messagePattern":"Not an entity type or supertype of an entity type: (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/internal/SessionFactoryImpl.java","lineNumber":470,"sourceCode":"\t\treturn eventListenerGroups;\n\t}\n\n\t@Override\n\t@Nonnull\n\tpublic <E> EntityListenerRegistration addListener(\n\t\t\t@Nonnull Class<E> entityClass,\n\t\t\t@Nonnull Class<? extends Annotation> callbackType,\n\t\t\t@Nonnull Consumer<? super E> callback) {\n\t\tfinal var type = CallbackType.fromCallbackAnnotation( callbackType );\n\t\tfinal List<EntityListenerRegistration> registrations = new ArrayList<>();\n\t\tgetMappingMetamodel().forEachEntityDescriptor( persister -> {\n\t\t\tfinal var mappedClass = persister.getMappedClass();\n\t\t\tif ( mappedClass != null && entityClass.isAssignableFrom( mappedClass ) ) {\n\t\t\t\tregistrations.add( addListener( entityClass, persister, type, callback ) );\n\t\t\t}\n\t\t} );\n\t\tif ( registrations.isEmpty() ) {\n\t\t\tthrow new IllegalArgumentException( \"Not an entity type or supertype of an entity type: \" + entityClass.getName() );\n\t\t}\n\t\treturn registrations.size() == 1\n\t\t\t\t? registrations.get( 0 )\n\t\t\t\t: () -> registrations.forEach( EntityListenerRegistration::cancel );\n\t}\n\n\tprivate static <E> EntityListenerRegistration addListener(\n\t\t\tClass<E> entityClass,\n\t\t\tEntityPersister persister,\n\t\t\tCallbackType callbackType,\n\t\t\tConsumer<? super E> callback) {\n\t\treturn persister.getEntityCallbacks().addListener(\n\t\t\t\tcallbackType,\n\t\t\t\tentity -> callback.accept( entityClass.cast( entity ) )\n\t\t);\n\t}\n\n\t@Override","sourceCodeStart":452,"sourceCodeEnd":488,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/internal/SessionFactoryImpl.java#L452-L488","documentation":"Error \"Not an entity type or supertype of an entity type: {}\" thrown in hibernate/hibernate-orm.","triggerScenarios":"Thrown when a metamodel lookup is done for a class that is not an entity or entity supertype.","commonSituations":"Typical situations: passing an embeddable or unmapped class to an entity lookup; wrong generic type argument.","solutions":["Pass an entity type (or supertype of entities) to the operation; check the class/name for correctness."],"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"}