{"record":{"id":"6308965fedf16c79","repo":"hibernate/hibernate-orm","slug":"passed-attribute-name-s-did-not-correspond-to-a-630896","errorCode":null,"errorMessage":"Passed attribute name [%s] did not correspond to a collection (set) reference [%s] relative to %s","messagePattern":"Passed attribute name \\[(.+?)\\] did not correspond to a collection \\(set\\) reference \\[(.+?)\\] relative to (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/query/sqm/tree/spi/domain/AbstractSqmFrom.java","lineNumber":571,"sourceCode":"\t\treturn joinSet( attributeName, JoinType.INNER );\n\t}\n\n\t@Nonnull\n\t@Override\n\t@SuppressWarnings(\"unchecked\")\n\tpublic <Y> SqmSetJoin<T, Y> joinSet(@Nonnull String attributeName, @Nonnull JoinType jt) {\n\t\tfinal var joinedPathSource = getReferencedPathSource().getSubPathSource( attributeName );\n\t\tif ( joinedPathSource instanceof SetPersistentAttribute ) {\n\t\t\tfinal var join = buildSetJoin(\n\t\t\t\t\t(SetPersistentAttribute<T, Y>) joinedPathSource,\n\t\t\t\t\tSqmJoinType.from( jt ),\n\t\t\t\t\tfalse\n\t\t\t);\n\t\t\taddSqmJoin( join );\n\t\t\treturn join;\n\t\t}\n\n\t\tthrow new IllegalArgumentException(\n\t\t\t\tString.format(\n\t\t\t\t\t\tLocale.ROOT,\n\t\t\t\t\t\t\"Passed attribute name [%s] did not correspond to a collection (set) reference [%s] relative to %s\",\n\t\t\t\t\t\tattributeName,\n\t\t\t\t\t\tjoinedPathSource,\n\t\t\t\t\t\tgetNavigablePath()\n\t\t\t\t)\n\t\t);\n\t}\n\n\t@Nonnull\n\t@Override\n\tpublic <Y> SqmListJoin<T, Y> joinList(@Nonnull String attributeName) {\n\t\treturn joinList( attributeName, JoinType.INNER );\n\t}\n\n\t@Nonnull\n\t@Override","sourceCodeStart":553,"sourceCodeEnd":589,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/spi/domain/AbstractSqmFrom.java#L553-L589","documentation":"AbstractSqmFrom.joinSet(attributeName, joinType) requires the resolved attribute to be a SetPersistentAttribute (java.util.Set mapping). Any other kind (bag/Collection, ordered List, Map, singular attribute) throws IllegalArgumentException with the attribute name, the resolved source and the navigable path.","triggerScenarios":"root.joinSet(\"tags\", JoinType.INNER) when tags is List<String> or Collection<String>; joinSet on a Map attribute or a singular @ManyToOne attribute.","commonSituations":"Field migrated from Set to List; generic helpers calling joinSet unconditionally; assuming 'set' means any collection.","solutions":["Use joinCollection for Collection/bag, joinList for ordered List, joinMap for Map, join for singular attributes.","Use the typed metamodel overloads join(SetAttribute) etc. so the compiler catches the mismatch.","Inspect the attribute via the metamodel (instanceof SetAttribute) before calling."],"exampleFix":"// before\ncustomerRoot.joinSet( \"orders\", JoinType.INNER ); // orders is List<Order>\n// after\ncustomerRoot.joinList( \"orders\", JoinType.INNER );","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"static boolean isSet(ManagedType<?> type, String attr) {\n    return type.getAttribute( attr ) instanceof jakarta.persistence.metamodel.SetAttribute;\n}","tryCatchPattern":null,"preventionTips":["Use join(SetAttribute) typed overloads from the metamodel where possible.","Guard string-based joinSet calls with a SetAttribute instanceof check.","Keep entity container types stable, or centralize join creation so kind changes only touch one place."],"tags":["hibernate","criteria-api","join","set","illegal-argument"],"backgroundTag":"wrong-collection-join-type","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}