hibernate/hibernate-orm · error · StrategySelectionException
Unable to resolve name [{}] as strategy [{}]
Error message
Unable to resolve name [{}] as strategy [{}] What it means
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.
Source
Thrown at hibernate-core/src/main/java/org/hibernate/boot/registry/selector/internal/StrategySelectorImpl.java:81
final var registered = namedStrategyImplementorMap.get( name );
if ( registered != null ) {
return (Class<T>) registered;
}
}
final var lazyServiceResolver = lazyStrategyImplementorByStrategyMap.get( strategy );
if ( lazyServiceResolver != null ) {
final var resolve = lazyServiceResolver.resolve( name );
if ( resolve != null ) {
return (Class<? extends T>) resolve;
}
}
try {
return classLoaderService.classForName( name );
}
catch (ClassLoadingException e) {
throw new StrategySelectionException(
"Unable to resolve name [" + name + "] as strategy [" + strategy.getName() + "]",
e
);
}
}
@Override
public <T> T resolveStrategy(Class<T> strategy, Object strategyReference) {
return resolveDefaultableStrategy( strategy, strategyReference, (T) null );
}
@Override
public <T> T resolveDefaultableStrategy(Class<T> strategy, Object strategyReference, final T defaultValue) {
return resolveDefaultableStrategy(
strategy,
strategyReference,
(Callable<T>) () -> defaultValue
);View on GitHub (pinned to fad1729dce)
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
Example fix
// before <property name="hibernate.dialect" value="MySQL57Dialect"/> <!-- alias removed in 6.x --> // after <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
Defensive patterns
Strategy: validation
Validate before calling
// Validate strategy names before boot
String dialect = config.get("hibernate.dialect");
try {
Class.forName(dialect); // or check against a whitelist of known short names
} catch (ClassNotFoundException e) {
throw new IllegalStateException("Unknown dialect name: " + dialect, e);
} Try / catch
try {
Class<? extends Dialect> d = strategySelector.selectStrategyImplementor(Dialect.class, name);
} catch (StrategySelectionException e) {
// e.getCause() is a ClassLoadingException: name is neither registered nor loadable
// fall back to the FQN of a known-good dialect
return org.hibernate.dialect.PostgreSQLDialect.class;
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Default resolver threw exception
- Cannot instantiate the class [{}] because it does not have a
- Unable to load class [" + className + "]
- Unknown TcclLookupPrecedence - {}
- Can't use this method on for strategy types which are embedd
AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22).
Data as JSON: /api/errors/55f8779889e49316.
Report an issue: GitHub.