{"record":{"id":"06e4189964896783","repo":"hibernate/hibernate-orm","slug":"property-path-is-annotated-any-and-must-dec","errorCode":null,"errorMessage":"Property '<path>' is annotated '@Any' and must declare at least one '@JoinColumn'","messagePattern":"Property '<path>' is annotated '@Any' and must declare at least one '@JoinColumn'","errorType":"exception","errorClass":"AnnotationException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/boot/model/internal/ColumnsBuilder.java","lineNumber":125,"sourceCode":"\t\t\t\t\t\t|| property.hasDirectAnnotationUsage( OneToOne.class ) ) ) {\n\t\t\tjoinColumns = buildDefaultJoinColumnsForToOne( property, inferredData );\n\t\t}\n\t\telse if ( joinColumns == null\n\t\t\t\t&& ( property.hasDirectAnnotationUsage( OneToMany.class )\n\t\t\t\t\t\t|| property.hasDirectAnnotationUsage( ElementCollection.class ) ) ) {\n\t\t\tfinal var oneToMany = property.getDirectAnnotationUsage( OneToMany.class );\n\t\t\tjoinColumns = AnnotatedJoinColumns.buildJoinColumns(\n\t\t\t\t\tnull,\n\t\t\t\t\toneToMany == null ? null : nullIfEmpty( oneToMany.mappedBy() ),\n\t\t\t\t\tentityBinder.getSecondaryTables(),\n\t\t\t\t\tpropertyHolder,\n\t\t\t\t\tinferredData,\n\t\t\t\t\tbuildingContext\n\t\t\t);\n\t\t}\n\t\telse if ( joinColumns == null\n\t\t\t\t&& property.hasDirectAnnotationUsage( Any.class ) ) {\n\t\t\tthrow new AnnotationException( \"Property '\" + getPath( propertyHolder, inferredData )\n\t\t\t\t\t+ \"' is annotated '@Any' and must declare at least one '@JoinColumn'\" );\n\t\t}\n\t\tif ( columns == null && !property.hasDirectAnnotationUsage( ManyToMany.class ) ) {\n\t\t\t//useful for collection of embedded elements\n\t\t\tcolumns = buildColumnFromNoAnnotation(\n\t\t\t\t\tproperty.getDirectAnnotationUsage( FractionalSeconds.class ),\n\t\t\t\t\tnullability,\n\t\t\t\t\tpropertyHolder,\n\t\t\t\t\tinferredData,\n\t\t\t\t\tentityBinder.getSecondaryTables(),\n\t\t\t\t\tbuildingContext\n\t\t\t);\n\t\t}\n\n\t\tif ( nullability == Nullability.FORCED_NOT_NULL ) {\n\t\t\t//force columns to not null\n\t\t\tfor ( AnnotatedColumn column : columns.getColumns() ) {\n\t\t\t\tcolumn.forceNotNull();","sourceCodeStart":107,"sourceCodeEnd":143,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/boot/model/internal/ColumnsBuilder.java#L107-L143","documentation":"Error \"Property '<path>' is annotated '@Any' and must declare at least one '@JoinColumn'\" thrown in hibernate/hibernate-orm.","triggerScenarios":"A '@JoinColumn' / 'referencedColumnName' does not line up with the columns mapped by the target entity.","commonSituations":"Composite foreign keys, associations to entities with secondary tables, or reordered/duplicated referencedColumnName values across multiple @JoinColumn declarations.","solutions":["Declare at least one @JoinColumn for the @Any property."],"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"}