{"record":{"id":"3966c721cf88d14f","repo":"hibernate/hibernate-orm","slug":"could-not-find-table-group-for-s","errorCode":null,"errorMessage":"Could not find table group for: %s","messagePattern":"Could not find table group for: (.+?)","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/sql/ast/tree/from/PluralTableGroup.java","lineNumber":29,"sourceCode":" * @author Christian Beikov\n */\npublic interface PluralTableGroup extends TableGroup {\n\n\tPluralAttributeMapping getModelPart();\n\n\tTableGroup getElementTableGroup();\n\n\tTableGroup getIndexTableGroup();\n\n\tdefault TableGroup getTableGroup(CollectionPart.Nature nature) {\n\t\tswitch ( nature ) {\n\t\t\tcase ELEMENT:\n\t\t\t\treturn getElementTableGroup();\n\t\t\tcase INDEX:\n\t\t\t\treturn getIndexTableGroup();\n\t\t}\n\n\t\tthrow new IllegalStateException( \"Could not find table group for: \" + nature );\n\t}\n}\n","sourceCodeStart":11,"sourceCodeEnd":32,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/from/PluralTableGroup.java#L11-L32","documentation":"PluralTableGroup only carries table groups for the ELEMENT and INDEX parts of a collection mapping. Its getTableGroup(CollectionPart.Nature) switch handles those two constants; every other Nature value falls through to an IllegalStateException. In Hibernate's enum that other value is ID (the idbag collection-id part), so the plural table group structurally has nothing to return for it.","triggerScenarios":"Calling pluralTableGroup.getTableGroup(CollectionPart.Nature.ID), e.g. while resolving a NavigablePath that addresses the '{collection-id}' part of an idbag mapping; generic code that iterates CollectionPart.Nature.values() and resolves each nature against a PluralTableGroup; custom SQM path resolution or result builders that look up collection parts by nature.","commonSituations":"Custom dialect functions, SQM extensions, or tooling that walks collection parts generically; idbag mappings whose collection-id path gets resolved against a standard plural table group; Hibernate upgrades where the Nature enum gains a constant the switch does not handle.","solutions":["Do not resolve Nature.ID through PluralTableGroup.getTableGroup - resolve the collection-id part via the PluralAttributeMapping instead","Switch on nature at the call site and handle/skip ID before calling getTableGroup","If you control the caller, use getElementTableGroup()/getIndexTableGroup() directly","Verify any idbag NavigablePath handling: the {collection-id} path must not be resolved against a plain plural table group"],"exampleFix":"// before\nTableGroup group = pluralTableGroup.getTableGroup( nature ); // throws for Nature.ID\n\n// after\nTableGroup group = switch ( nature ) {\n    case ELEMENT -> pluralTableGroup.getElementTableGroup();\n    case INDEX -> pluralTableGroup.getIndexTableGroup();\n    case ID -> null; // resolve collection-id via PluralAttributeMapping, not the table group\n};","handlingStrategy":"type-guard","validationCode":"TableGroup resolveTableGroup(PluralTableGroup group, CollectionPart.Nature nature) {\n    return switch ( nature ) {\n        case ELEMENT -> group.getElementTableGroup();\n        case INDEX -> group.getIndexTableGroup();\n        default -> null;\n    };\n}","typeGuard":"boolean isResolvableNature(CollectionPart.Nature nature) {\n    return nature == CollectionPart.Nature.ELEMENT || nature == CollectionPart.Nature.INDEX;\n}","tryCatchPattern":"try { ... } catch ( IllegalStateException e ) { if ( e.getMessage() != null && e.getMessage().startsWith( \"Could not find table group for\" ) ) { /* resolve via PluralAttributeMapping instead */ } else throw e; }","preventionTips":["Never pass CollectionPart.Nature.ID (or enum values other than ELEMENT/INDEX) to PluralTableGroup.getTableGroup","Resolve the idbag collection-id part through the PluralAttributeMapping, not through table groups","When iterating Nature.values(), handle unknown constants explicitly with a default branch"],"tags":["hibernate","orm","sql-ast","collection-mapping","internal-api","illegal-state"],"backgroundTag":"unsupported-enum-value","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}