{"record":{"id":"55f8779889e49316","repo":"hibernate/hibernate-orm","slug":"unable-to-resolve-name-as-strategy","errorCode":null,"errorMessage":"Unable to resolve name [{}] as strategy [{}]","messagePattern":"Unable to resolve name \\[(.+?)\\] as strategy \\[(.+?)\\]","errorType":"exception","errorClass":"StrategySelectionException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/boot/registry/selector/internal/StrategySelectorImpl.java","lineNumber":81,"sourceCode":"\t\t\tfinal var registered = namedStrategyImplementorMap.get( name );\n\t\t\tif ( registered != null ) {\n\t\t\t\treturn (Class<T>) registered;\n\t\t\t}\n\t\t}\n\n\t\tfinal var lazyServiceResolver = lazyStrategyImplementorByStrategyMap.get( strategy );\n\t\tif ( lazyServiceResolver != null ) {\n\t\t\tfinal var resolve = lazyServiceResolver.resolve( name );\n\t\t\tif ( resolve != null ) {\n\t\t\t\treturn (Class<? extends T>) resolve;\n\t\t\t}\n\t\t}\n\n\t\ttry {\n\t\t\treturn classLoaderService.classForName( name );\n\t\t}\n\t\tcatch (ClassLoadingException e) {\n\t\t\tthrow new StrategySelectionException(\n\t\t\t\t\t\"Unable to resolve name [\" + name + \"] as strategy [\" + strategy.getName() + \"]\",\n\t\t\t\t\te\n\t\t\t);\n\t\t}\n\t}\n\n\t@Override\n\tpublic <T> T resolveStrategy(Class<T> strategy, Object strategyReference) {\n\t\treturn resolveDefaultableStrategy( strategy, strategyReference, (T) null );\n\t}\n\n\t@Override\n\tpublic <T> T resolveDefaultableStrategy(Class<T> strategy, Object strategyReference, final T defaultValue) {\n\t\treturn resolveDefaultableStrategy(\n\t\t\t\tstrategy,\n\t\t\t\tstrategyReference,\n\t\t\t\t(Callable<T>) () -> defaultValue\n\t\t);","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/boot/registry/selector/internal/StrategySelectorImpl.java#L63-L99","documentation":"selectStrategyImplementor(strategy, name) resolves a strategy in three steps: registered short names, the strategy's lazy resolver if one exists, and finally classForName(name). When all fail, the ClassLoadingException is wrapped as StrategySelectionException 'Unable to resolve name [...] as strategy [...]' - the name is neither a registered strategy name nor a loadable class name.","triggerScenarios":"Setting a strategy by name where the name is wrong: hibernate.dialect=my.Dialect that does not exist, a Hibernate 5 dialect alias removed in Hibernate 6, jta.platform short names, or a property value carrying whitespace/quotes.","commonSituations":"Upgrading Hibernate 5 to 6 where versioned dialect shorthands (e.g. MySQL57Dialect) were removed in favor of family dialects; typos in class names; missing jar containing the custom strategy class; quoted property values in YAML/XML.","solutions":["Use the fully-qualified class name of an existing implementation, or a currently registered short name","After a Hibernate 5 to 6 upgrade, replace removed versioned dialect aliases with the un-versioned family dialect (e.g. org.hibernate.dialect.MySQLDialect)","Verify the class is on the runtime classpath and the property value has no trailing whitespace or quote characters"],"exampleFix":"// before\n<property name=\"hibernate.dialect\" value=\"MySQL57Dialect\"/> <!-- alias removed in 6.x -->\n\n// after\n<property name=\"hibernate.dialect\" value=\"org.hibernate.dialect.MySQLDialect\"/>","handlingStrategy":"validation","validationCode":"// Validate strategy names before boot\nString dialect = config.get(\"hibernate.dialect\");\ntry {\n    Class.forName(dialect); // or check against a whitelist of known short names\n} catch (ClassNotFoundException e) {\n    throw new IllegalStateException(\"Unknown dialect name: \" + dialect, e);\n}","typeGuard":null,"tryCatchPattern":"try {\n    Class<? extends Dialect> d = strategySelector.selectStrategyImplementor(Dialect.class, name);\n} catch (StrategySelectionException e) {\n    // e.getCause() is a ClassLoadingException: name is neither registered nor loadable\n    // fall back to the FQN of a known-good dialect\n    return org.hibernate.dialect.PostgreSQLDialect.class;\n}","preventionTips":["Pin the fully-qualified dialect class in config instead of version-sensitive short names","After major Hibernate upgrades, re-check every strategy name property","Trim and unquote property values in YAML/XML before passing them to Hibernate"],"tags":["hibernate","strategy","configuration","dialect","classloading"],"backgroundTag":"unknown-strategy-name","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}