hibernate/hibernate-orm · error · SyntaxException
Missing instantiation target type
Error message
Missing instantiation target type
What it means
Error "Missing instantiation target type" thrown in hibernate/hibernate-orm.
Source
Thrown at hibernate-core/src/main/java/org/hibernate/query/hql/internal/SemanticQueryBuilder.java:1542
throw new SemanticException( "Missing constructor for type '" + typeName + "'", query );
}
}
return dynamicInstantiation;
}
@Override
public SqmDynamicInstantiation<?> visitInstantiationTarget(HqlParser.InstantiationTargetContext ctx) {
if ( ctx.MAP() != null ) {
return forMapInstantiation( mapJavaType, nodeBuilder() );
}
else if ( ctx.LIST() != null ) {
return forListInstantiation( listJavaType, nodeBuilder() );
}
else {
final var simplePath = ctx.simplePath();
if ( simplePath == null ) {
throw new SyntaxException( "Missing instantiation target type" );
}
final String className = instantiationClassName( simplePath );
try {
return forClassInstantiation( resolveInstantiationTargetType( className ), nodeBuilder() );
}
catch (ClassLoadingException e) {
throw new SemanticException( "Could not resolve class '" + className + "' named for instantiation", query );
}
}
}
private String instantiationClassName(HqlParser.SimplePathContext ctx) {
final String name = ctx.getText();
return expectedResultTypeName != null && expectedResultTypeShortName.equals( name )
? expectedResultTypeName
: name;
}
View on GitHub (pinned to fad1729dce)
Solutions
- Specify a target type for the dynamic instantiation ('new com.foo.Dto(...)').
- Check the query syntax of the select clause.
When it happens
Trigger: A dynamic instantiation (select new) target cannot be constructed.
Common situations: Using 'select new SomeClass(...)' where the class is missing or has no matching constructor.
AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22).
Data as JSON: /api/errors/fdf76b9587f0c90a.
Report an issue: GitHub.