{"record":{"id":"1ee1769ed73ae713","repo":"hibernate/hibernate-orm","slug":"could-not-instantiate-query-result-type-expected","errorCode":null,"errorMessage":"Could not instantiate query result type - expected '{}' but found '{}({})' in","messagePattern":"Could not instantiate query result type - expected '(.+?)' but found '(.+?)\\((.+?)\\)' in","errorType":"exception","errorClass":"InstantiationException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/jpa/spi/NativeQueryConstructorTransformer.java","lineNumber":122,"sourceCode":"\t\t\treturn ctor.newInstance( tuple );\n\t\t}\n\t\tcatch (Exception e) {\n\t\t\tfinal var message = new StringBuilder();\n\t\t\tmessage.append( \"Could not instantiate query result type - expected '\" )\n\t\t\t\t\t.append( constructorSignature( ctor ) )\n\t\t\t\t\t.append( \"' but found '\" )\n\t\t\t\t\t.append( ctor.getDeclaringClass().getSimpleName() )\n\t\t\t\t\t.append( '(' );\n\n\t\t\tfor ( int i = 0; i < tuple.length; i++ ) {\n\t\t\t\tfinal Object value = tuple[i];\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tmessage.append( \", \" );\n\t\t\t\t}\n\t\t\t\tmessage.append( value == null ? \"null\" : value.getClass().getSimpleName() );\n\t\t\t}\n\t\t\tmessage.append( \")' in\" );\n\t\t\tthrow new InstantiationException( message.toString(), resultClass, e );\n\t\t}\n\t}\n\n\t@Override\n\tpublic boolean equals(Object obj) {\n\t\treturn obj instanceof NativeQueryConstructorTransformer<?> that\n\t\t\t&& this.resultClass == that.resultClass;\n\t\t\t// should be safe to ignore the cached constructor here\n\t}\n\n\t@Override\n\tpublic int hashCode() {\n\t\treturn resultClass.hashCode();\n\t}\n}\n","sourceCodeStart":104,"sourceCodeEnd":138,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/jpa/spi/NativeQueryConstructorTransformer.java#L104-L138","documentation":"Error \"Could not instantiate query result type - expected '{}' but found '{}({})' in\" thrown in hibernate/hibernate-orm.","triggerScenarios":"Thrown at hibernate-core/src/main/java/org/hibernate/jpa/spi/NativeQueryConstructorTransformer.java:122 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Align the query's selected column types/count with the constructor signature of the result class."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}