{"record":{"id":"ab7519028f750d8a","repo":"hibernate/hibernate-orm","slug":"interface-clazz-getname-may-not-be-annotated","errorCode":null,"errorMessage":"Interface '<clazz.getName()>' may not be annotated '@Entity'","messagePattern":"Interface '<clazz\\.getName\\(\\)>' may not be annotated '@Entity'","errorType":"exception","errorClass":"MappingException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/boot/model/source/internal/annotations/AnnotationMetadataSourceProcessorImpl.java","lineNumber":241,"sourceCode":"\t}\n\n\tprivate List<ClassDetails> orderAndFillHierarchy(LinkedHashSet<ClassDetails> original) {\n\t\tfinal LinkedHashSet<ClassDetails> copy = new LinkedHashSet<>( original.size() );\n\t\tinsertMappedSuperclasses( original, copy );\n\t\t// order the hierarchy\n\t\tfinal List<ClassDetails> workingCopy = new ArrayList<>( copy );\n\t\tfinal List<ClassDetails> newList = new ArrayList<>( copy.size() );\n\t\twhile ( !workingCopy.isEmpty() ) {\n\t\t\tfinal var clazz = workingCopy.get( 0 );\n\t\t\torderHierarchy( workingCopy, newList, copy, clazz );\n\t\t}\n\t\treturn newList;\n\t}\n\n\tprivate void insertMappedSuperclasses(LinkedHashSet<ClassDetails> original, LinkedHashSet<ClassDetails> copy) {\n\t\tfor ( var clazz : original ) {\n\t\t\tif ( clazz.isInterface() && isEntity( clazz ) ) {\n\t\t\t\tthrow new MappingException( \"Interface '\" + clazz.getName() + \"' may not be annotated '@Entity'\" );\n\t\t\t}\n\t\t\telse if ( isMappedSuperclass( clazz ) ) {\n\t\t\t\t// Skip class with explicit @MappedSuperclass annotation\n\t\t\t\t// the class will be discovered analyzing the implementing class\n\t\t\t}\n\t\t\telse {\n\t\t\t\tcopy.add( clazz );\n\t\t\t\tvar superClass = clazz.getSuperClass();\n\t\t\t\twhile ( superClass != null\n\t\t\t\t\t\t&& !isObjectClass( superClass )\n\t\t\t\t\t\t&& !copy.contains( superClass ) ) {\n\t\t\t\t\tif ( isEntity( superClass ) || isMappedSuperclass( superClass ) ) {\n\t\t\t\t\t\tcopy.add( superClass );\n\t\t\t\t\t}\n\t\t\t\t\tsuperClass = superClass.getSuperClass();\n\t\t\t\t}\n\t\t\t}\n\t\t}","sourceCodeStart":223,"sourceCodeEnd":259,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/boot/model/source/internal/annotations/AnnotationMetadataSourceProcessorImpl.java#L223-L259","documentation":"Error \"Interface '<clazz.getName()>' may not be annotated '@Entity'\" thrown in hibernate/hibernate-orm.","triggerScenarios":"An entity mapping annotation or bootstrap configuration violates a Hibernate mapping rule.","commonSituations":"Annotation mapping mistakes: inverse-side @Id associations, @Column on @OneToOne, unmapped association targets, mismatched @EnumeratedValue/@Temporal usage, duplicate sequence generators.","solutions":["Remove @Entity from the interface; map a concrete class instead, or use the interface only as a target of associations via targetEntity."],"exampleFix":"Remove @Entity from the interface; map a concrete class instead, or use the interface only as a target of associations via targetEntity.","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"}