hibernate/hibernate-orm · error · InstantiationException
Could not instantiate query result type - expected '{}' but
Error message
Could not instantiate query result type - expected '{}' but found '{}({})' in What it means
Error "Could not instantiate query result type - expected '{}' but found '{}({})' in" thrown in hibernate/hibernate-orm.
Source
Thrown at hibernate-core/src/main/java/org/hibernate/jpa/spi/NativeQueryConstructorTransformer.java:122
return ctor.newInstance( tuple );
}
catch (Exception e) {
final var message = new StringBuilder();
message.append( "Could not instantiate query result type - expected '" )
.append( constructorSignature( ctor ) )
.append( "' but found '" )
.append( ctor.getDeclaringClass().getSimpleName() )
.append( '(' );
for ( int i = 0; i < tuple.length; i++ ) {
final Object value = tuple[i];
if ( i > 0 ) {
message.append( ", " );
}
message.append( value == null ? "null" : value.getClass().getSimpleName() );
}
message.append( ")' in" );
throw new InstantiationException( message.toString(), resultClass, e );
}
}
@Override
public boolean equals(Object obj) {
return obj instanceof NativeQueryConstructorTransformer<?> that
&& this.resultClass == that.resultClass;
// should be safe to ignore the cached constructor here
}
@Override
public int hashCode() {
return resultClass.hashCode();
}
}
View on GitHub (pinned to fad1729dce)
Solutions
- Align the query's selected column types/count with the constructor signature of the result class.
When it happens
Trigger: Thrown at hibernate-core/src/main/java/org/hibernate/jpa/spi/NativeQueryConstructorTransformer.java:122 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22).
Data as JSON: /api/errors/1ee1769ed73ae713.
Report an issue: GitHub.