{"record":{"id":"734c358ab305c3f9","repo":"hibernate/hibernate-orm","slug":"no-fetch-profile-named","errorCode":null,"errorMessage":"No fetch profile named '","messagePattern":"No fetch profile named '","errorType":"exception","errorClass":"UnknownProfileException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/engine/spi/LoadQueryInfluencers.java","lineNumber":291,"sourceCode":"//\t\tfinal String parameterName = filterParameterName.substring( dot + 1 );\n//\t\treturn new String[] { filterName, parameterName };\n//\t}\n\n\n\t// fetch profile support ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n\tpublic boolean hasEnabledFetchProfiles() {\n\t\treturn enabledFetchProfileNames != null && !enabledFetchProfileNames.isEmpty();\n\t}\n\n\t@Nonnull\n\tpublic Set<String> getEnabledFetchProfileNames() {\n\t\treturn enabledFetchProfileNames == null ? emptySet() : enabledFetchProfileNames;\n\t}\n\n\tprivate void checkFetchProfileName(@Nonnull String name) {\n\t\tif ( !sessionFactory.containsFetchProfileDefinition( name ) ) {\n\t\t\tthrow new UnknownProfileException( name );\n\t\t}\n\t}\n\n\tpublic boolean isFetchProfileEnabled(@Nonnull String name) throws UnknownProfileException {\n\t\tcheckFetchProfileName( name );\n\t\treturn enabledFetchProfileNames != null && enabledFetchProfileNames.contains( name );\n\t}\n\n\tpublic void enableFetchProfile(@Nonnull String name) throws UnknownProfileException {\n\t\tcheckFetchProfileName( name );\n\t\tif ( enabledFetchProfileNames == null ) {\n\t\t\tenabledFetchProfileNames = new HashSet<>();\n\t\t}\n\t\tenabledFetchProfileNames.add( name );\n\t}\n\n\tpublic void disableFetchProfile(@Nonnull String name) throws UnknownProfileException {\n\t\tcheckFetchProfileName( name );","sourceCodeStart":273,"sourceCodeEnd":309,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/engine/spi/LoadQueryInfluencers.java#L273-L309","documentation":"LoadQueryInfluencers.checkFetchProfileName() validates every fetch-profile name against the SessionFactory metadata before enabling or checking it; unknown names throw UnknownProfileException with the message 'No fetch profile named \\'<name\\>''. Fetch profiles are part of the mapping and must be declared at bootstrap — there is no runtime registration.","triggerScenarios":"session.enableFetchProfile(name) or session.isFetchProfileEnabled(name) with a name that has no @FetchProfile/@FetchProfile.FetchOverride annotation (on the entity or package-info) and no matching <fetch-profile> element in the ORM mapping XML.","commonSituations":"Typo or case mismatch in the profile name string; @FetchProfile annotation placed on a non-scanned class or missing the entity override; profile declared in a hbm.xml/orm.xml that is not listed in persistence.xml; package restructuring that dropped the annotated package-info from entity scanning.","solutions":["Declare the profile in the mapping: @FetchProfile(name = \"order.withItems\", entityOverrides = @FetchProfile.FetchOverride(entity = Order.class, association = \"items\", fetch = FetchType.EAGER)) on the entity or package-info, or the equivalent <fetch-profile> XML","Verify the enabled name matches the declared name exactly (case-sensitive)","Guard with sessionFactory.containsFetchProfileDefinition(name) before enabling, so misconfiguration surfaces as your own clear error"],"exampleFix":"// before\nsession.enableFetchProfile(\"order-with-items\"); // nothing declared -> UnknownProfileException\n\n// after\n@Entity\n@FetchProfile(name = \"order.withItems\",\n    entityOverrides = @FetchProfile.FetchOverride(entity = Order.class, association = \"items\", fetch = FetchType.EAGER))\npublic class Order { ... }\n// ...\nsession.enableFetchProfile(\"order.withItems\");","handlingStrategy":"validation","validationCode":"if (!sessionFactory.containsFetchProfileDefinition(profileName)) {\n    throw new IllegalArgumentException(\"No fetch profile named '\" + profileName + \"' is defined in the SessionFactory\");\n}\nsession.enableFetchProfile(profileName);","typeGuard":null,"tryCatchPattern":"try {\n    session.enableFetchProfile(name);\n} catch (UnknownProfileException e) {\n    log.warn(\"Fetch profile '{}' is not defined; continuing without it\", name);\n}","preventionTips":["Declare all fetch profiles as constants next to the @FetchProfile annotation and reference the constant, not a string literal","Add a startup assertion that every profile name you enable exists: sessionFactory.containsFetchProfileDefinition(name)","Keep annotation metadata (package-info with @FetchProfile) inside scanned packages"],"tags":["hibernate","fetch-profile","mapping","unknown-name","metadata"],"backgroundTag":"undefined-fetch-profile","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}