{"record":{"id":"99a84195c3683f2e","repo":"hibernate/hibernate-orm","slug":"entity-classname-is-a-subclass-in-a-single-ta","errorCode":null,"errorMessage":"Entity '<className>' is a subclass in a 'SINGLE_TABLE' hierarchy and may not be annotated '@Table' (the root class declares the table mapping for the hierarchy)","messagePattern":"Entity '<className>' is a subclass in a 'SINGLE_TABLE' hierarchy and may not be annotated '@Table' \\(the root class declares the table mapping for the hierarchy\\)","errorType":"exception","errorClass":"AnnotationException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/boot/model/internal/EntityBinder.java","lineNumber":853,"sourceCode":"\t\t\tschema = tableAnnotation.schema();\n\t\t\tcatalog = tableAnnotation.catalog();\n\t\t\tuniqueConstraints = tableAnnotation.uniqueConstraints();\n\t\t}\n\t\telse {\n\t\t\t//might be no @Table annotation on the annotated class\n\t\t\tschema = \"\";\n\t\t\ttable = \"\";\n\t\t\tcatalog = \"\";\n\t\t\tuniqueConstraints = new UniqueConstraint[0];\n\t\t}\n\n\t\tif ( inheritanceState.hasTable() ) {\n\t\t\tcreateTable( inheritanceState, superEntity, schema, table, catalog, uniqueConstraints );\n\t\t}\n\t\telse {\n\t\t\t// if we get here we have SINGLE_TABLE inheritance\n\t\t\tif ( tableAnnotation != null ) {\n\t\t\t\tthrow new AnnotationException( \"Entity '\" + annotatedClass.getName()\n\t\t\t\t\t\t+ \"' is a subclass in a 'SINGLE_TABLE' hierarchy and may not be annotated '@Table'\"\n\t\t\t\t\t\t+ \" (the root class declares the table mapping for the hierarchy)\");\n\t\t\t}\n\t\t\t// we at least need to properly set up the EntityTableXref\n\t\t\tbindTableForDiscriminatedSubclass( superEntity.getEntityName() );\n\t\t}\n\t}\n\n\tprivate void createTable(\n\t\t\tInheritanceState inheritanceState,\n\t\t\tPersistentClass superEntity,\n\t\t\tString schema,\n\t\t\tString table,\n\t\t\tString catalog,\n\t\t\tUniqueConstraint[] uniqueConstraints) {\n\t\tfinal var models = modelsContext();\n\t\tfinal var rowId = annotatedClass.getAnnotationUsage( RowId.class, models );\n\t\tfinal var view = annotatedClass.getAnnotationUsage( View.class, models );","sourceCodeStart":835,"sourceCodeEnd":871,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/boot/model/internal/EntityBinder.java#L835-L871","documentation":"Error \"Entity '<className>' is a subclass in a 'SINGLE_TABLE' hierarchy and may not be annotated '@Table' (the root class declares the table mapping for the hierarchy)\" thrown in hibernate/hibernate-orm.","triggerScenarios":"An annotation restricted to the root of an inheritance hierarchy is placed on a subclass (or the hierarchy rules are otherwise violated).","commonSituations":"SINGLE_TABLE/JOINED hierarchies where @Table, @DiscriminatorColumn, @DiscriminatorFormula, @Cache, @Immutable, @Id or @Version are declared on the wrong class of the hierarchy.","solutions":["Remove @Table from the SINGLE_TABLE subclass; declare the table on the hierarchy root."],"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"}