{"record":{"id":"b58a0206d57b2ae3","repo":"hibernate/hibernate-orm","slug":"could-not-generate-fetch-s-s","errorCode":null,"errorMessage":"Could not generate fetch : %s -> %s","messagePattern":"Could not generate fetch : (.+?) -> (.+?)","errorType":"exception","errorClass":"HibernateException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/query/sqm/sql/spi/BaseSqmToSqlAstConverter.java","lineNumber":9187,"sourceCode":"\t\t\tString alias) {\n\t\t// fetch has access to its parent in addition to the parent having its fetches.\n\t\t//\n\t\t// we could sever the parent -> fetch link ... it would not be \"seen\" while walking\n\t\t// but it would still have access to its parent info - and be able to access its\n\t\t// \"initializing\" state as part of AfterLoadAction\n\n\t\ttry {\n\t\t\treturn fetchParent.generateFetchableFetch(\n\t\t\t\t\tfetchable,\n\t\t\t\t\tfetchablePath,\n\t\t\t\t\tfetchTiming,\n\t\t\t\t\tjoined,\n\t\t\t\t\talias,\n\t\t\t\t\tthis\n\t\t\t);\n\t\t}\n\t\tcatch (RuntimeException e) {\n\t\t\tthrow new HibernateException(\n\t\t\t\t\tString.format(\n\t\t\t\t\t\t\tLocale.ROOT,\n\t\t\t\t\t\t\t\"Could not generate fetch : %s -> %s\",\n\t\t\t\t\t\t\tfetchParent.getNavigablePath(),\n\t\t\t\t\t\t\tfetchable.getFetchableName()\n\t\t\t\t\t),\n\t\t\t\t\te\n\t\t\t);\n\t\t}\n\t}\n//\n//\tprivate void applyOrdering(TableGroup tableGroup, PluralAttributeMapping pluralAttributeMapping) {\n//\t\tif ( pluralAttributeMapping.getOrderByFragment() != null ) {\n//\t\t\tapplyOrdering( tableGroup, pluralAttributeMapping.getOrderByFragment() );\n//\t\t}\n//\n//\t\tif ( pluralAttributeMapping.getManyToManyOrderByFragment() != null ) {\n//\t\t\tapplyOrdering( tableGroup, pluralAttributeMapping.getManyToManyOrderByFragment() );","sourceCodeStart":9169,"sourceCodeEnd":9205,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/spi/BaseSqmToSqlAstConverter.java#L9169-L9205","documentation":"A pass-through wrapper: the underlying fetch construction (fetchParent.generateFetchableFetch) threw a RuntimeException, and Hibernate rethrows it as a HibernateException naming the fetch parent path and fetchable name with the original exception as cause. The real failure is always in the cause - this message only tells you which fetch broke.","triggerScenarios":"Any fetch whose construction fails: multiple-bag conflicts inside a fetched association, dialects lacking a type needed by a fetched column, circular fetch paths, subclass-table mappings with missing selectable mappings, or any of the other translation errors occurring inside fetch processing.","commonSituations":"Deep or wide entity graphs; enabling join fetch on a mapping that worked lazily; upgrading Hibernate where a mapped type became stricter; dialect-specific column types inside fetched embeddables.","solutions":["Read the cause exception first - fix that, not this message","Remove or narrow the failing fetch (named by parent path -> fetchable) and retry to confirm","If the cause is a bag conflict, apply the multiple-bag fixes (OrderColumn/Set/split queries)","Reduce fetch depth or fetch the problem collection lazily with batch fetching"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    return query.getResultList();\n} catch (org.hibernate.HibernateException e) {\n    if (e.getMessage() != null && e.getMessage().startsWith(\"Could not generate fetch\")) {\n    \tlog.error(\"Fetch {} failed; cause: {}\", e.getMessage(), e.getCause(), e);\n    \treturn runWithoutFetch(fetchName); // retry with the offending fetch removed (e.g. LAZY hint)\n    }\n    throw e;\n}","preventionTips":["Always log the cause chain - this exception is only a wrapper","Keep entity graphs shallow and test every graph against a real SessionFactory","Introduce fetches incrementally so the breaking fetch is identifiable in bisect history"],"tags":["hibernate","fetch","wrapper-exception","query-translation"],"backgroundTag":"fetch-generation-failure","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}