hibernate/hibernate-orm · error · InstantiationException
Result class must have exactly one constructor with {} param
Error message
Result class must have exactly one constructor with {} parameters - found ['{}'] in What it means
Error "Result class must have exactly one constructor with {} parameters - found ['{}'] in" thrown in hibernate/hibernate-orm.
Source
Thrown at hibernate-core/src/main/java/org/hibernate/jpa/spi/NativeQueryConstructorTransformer.java:94
final var message = new StringBuilder();
message.append( "Result class" )
.append( " must have exactly one constructor with " )
.append( elements.length )
.append( " parameters - found ['" );
boolean first = true;
for ( var c : resultClass.getDeclaredConstructors() ) {
if ( c.getParameterCount() == elements.length ) {
if ( !first ) {
message.append( "', '" );
}
message.append( constructorSignature( c ) );
first = false;
}
}
message.append( "'] in" );
throw new InstantiationException( message.toString(), resultClass );
}
}
return constructor;
}
@Override
public T transformTuple(Object[] tuple, String[] aliases) {
final var ctor = constructor( tuple );
try {
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( '(' );View on GitHub (pinned to fad1729dce)
Solutions
- Add a single constructor whose parameter count matches the query's selected columns, or adjust the SELECT list to match an existing constructor.
When it happens
Trigger: Thrown at hibernate-core/src/main/java/org/hibernate/jpa/spi/NativeQueryConstructorTransformer.java:94 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/e3d23928fc42800f.
Report an issue: GitHub.