{"record":{"id":"af030cd09da921c2","repo":"hibernate/hibernate-orm","slug":"invalid-class-annotated-both-embeddable-and-m","errorCode":null,"errorMessage":"Invalid class annotated both '@Embeddable' and '@MappedSuperclass': '{}'","messagePattern":"Invalid class annotated both '@Embeddable' and '@MappedSuperclass': '(.+?)'","errorType":"exception","errorClass":"AnnotationException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/boot/internal/InFlightMetadataCollectorImpl.java","lineNumber":1252,"sourceCode":"\tpublic AnnotatedClassType addClassType(ClassDetails clazz) {\n\t\tfinal var type = getAnnotatedClassType( clazz );\n\t\tannotatedClassTypeMap.put( clazz.getName(), type );\n\t\treturn type;\n\t}\n\n\tprivate static AnnotatedClassType getAnnotatedClassType(ClassDetails clazz) {\n\t\tif ( isEntity( clazz) ) {\n\t\t\tif ( isEmbeddable( clazz ) ) {\n\t\t\t\tthrow new AnnotationException( \"Invalid class annotated both '@Entity' and '@Embeddable': '\" + clazz.getName() + \"'\" );\n\t\t\t}\n\t\t\telse if ( isMappedSuperclass( clazz ) ) {\n\t\t\t\tthrow new AnnotationException( \"Invalid class annotated both '@Entity' and '@MappedSuperclass': '\" + clazz.getName() + \"'\" );\n\t\t\t}\n\t\t\treturn AnnotatedClassType.ENTITY;\n\t\t}\n\t\telse if ( isEmbeddable( clazz ) ) {\n\t\t\tif ( isMappedSuperclass( clazz ) ) {\n\t\t\t\tthrow new AnnotationException( \"Invalid class annotated both '@Embeddable' and '@MappedSuperclass': '\" + clazz.getName() + \"'\" );\n\t\t\t}\n\t\t\treturn AnnotatedClassType.EMBEDDABLE;\n\t\t}\n\t\telse if ( isMappedSuperclass( clazz ) ) {\n\t\t\treturn AnnotatedClassType.MAPPED_SUPERCLASS;\n\t\t}\n\t\telse if ( clazz.hasDirectAnnotationUsage( Imported.class ) ) {\n\t\t\treturn AnnotatedClassType.IMPORTED;\n\t\t}\n\t\telse {\n\t\t\treturn AnnotatedClassType.NONE;\n\t\t}\n\t}\n\n\t@Override\n\tpublic void addMappedSuperclass(Class<?> type, MappedSuperclass mappedSuperclass) {\n\t\tif ( mappedSuperClasses == null ) {\n\t\t\tmappedSuperClasses = new HashMap<>();","sourceCodeStart":1234,"sourceCodeEnd":1270,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/boot/internal/InFlightMetadataCollectorImpl.java#L1234-L1270","documentation":"Error \"Invalid class annotated both '@Embeddable' and '@MappedSuperclass': '{}'\" thrown in hibernate/hibernate-orm.","triggerScenarios":"A class carries a combination of type annotations that are mutually exclusive.","commonSituations":"Annotating one class with @Entity plus @Embeddable or @MappedSuperclass, or @Embeddable plus @MappedSuperclass, e.g. after refactoring an entity hierarchy.","solutions":["Remove either @Embeddable or @MappedSuperclass from the class.","If the class is a shared base for embeddables, annotate only with @MappedSuperclass; concrete embeddables get @Embeddable.","Check for accidental annotation duplication through copy-paste in the domain model."],"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"}