{"record":{"id":"62f28f3b9f53af25","repo":"hibernate/hibernate-orm","slug":"discriminator-mapping-s-named-both-column-an","errorCode":null,"errorMessage":"discriminator mapping [%s] named both <column/> and <formula/>, but only one or other allowed","messagePattern":"discriminator mapping \\[(.+?)\\] named both <column/> and <formula/>, but only one or other allowed","errorType":"exception","errorClass":"MappingException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/boot/model/source/internal/hbm/EntityHierarchySourceImpl.java","lineNumber":200,"sourceCode":"\t\t\t\t\t}\n\n\t\t\t\t\t@Override\n\t\t\t\t\tpublic String getFormulaAttribute() {\n\t\t\t\t\t\treturn jaxbDiscriminatorMapping.getFormulaAttribute();\n\t\t\t\t\t}\n\n\t\t\t\t\t@Override\n\t\t\t\t\tpublic String getColumnAttribute() {\n\t\t\t\t\t\treturn jaxbDiscriminatorMapping.getColumnAttribute();\n\t\t\t\t\t}\n\n\t\t\t\t\tprivate List columnOrFormulas;\n\t\t\t\t\t@Override\n\t\t\t\t\tpublic List getColumnOrFormulaElements() {\n\t\t\t\t\t\tif ( columnOrFormulas == null ) {\n\t\t\t\t\t\t\tif ( jaxbDiscriminatorMapping.getColumn() != null ) {\n\t\t\t\t\t\t\t\tif ( jaxbDiscriminatorMapping.getFormula() != null ) {\n\t\t\t\t\t\t\t\t\tthrow new MappingException(\n\t\t\t\t\t\t\t\t\t\t\tString.format(\n\t\t\t\t\t\t\t\t\t\t\t\t\tLocale.ENGLISH,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\"discriminator mapping [%s] named both <column/> and <formula/>, but only one or other allowed\",\n\t\t\t\t\t\t\t\t\t\t\t\t\trootEntitySource.getEntityNamingSource().getEntityName()\n\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\trootEntitySource.sourceMappingDocument().getOrigin()\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\t\tcolumnOrFormulas = Collections.singletonList( jaxbDiscriminatorMapping.getColumn() );\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\tif ( jaxbDiscriminatorMapping.getFormula() != null ) {\n\t\t\t\t\t\t\t\t\tcolumnOrFormulas = Collections.singletonList( jaxbDiscriminatorMapping.getFormula() );\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\t\tcolumnOrFormulas = Collections.emptyList();","sourceCodeStart":182,"sourceCodeEnd":218,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/boot/model/source/internal/hbm/EntityHierarchySourceImpl.java#L182-L218","documentation":"The <discriminator> mapping of an entity declares both a <column/> element and a <formula/> element (or both attributes). A discriminator may be backed by exactly one of a column or a formula; remove the unused declaration.","triggerScenarios":"An hbm.xml / orm.xml mapping document violates a mapping rule during bootstrap.","commonSituations":"Legacy XML mappings with invalid combinations (column+formula, mixed inheritance, missing identifiers, bad extends references).","solutions":["Keep either the <column/> or the <formula/> mapping on the discriminator, not both."],"exampleFix":"Keep either the <column/> or the <formula/> mapping on the discriminator, not both.","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}