{"record":{"id":"e3d23928fc42800f","repo":"hibernate/hibernate-orm","slug":"result-class-must-have-exactly-one-constructor-wit","errorCode":null,"errorMessage":"Result class must have exactly one constructor with {} parameters - found ['{}'] in","messagePattern":"Result class must have exactly one constructor with (.+?) parameters - found \\['(.+?)'\\] in","errorType":"exception","errorClass":"InstantiationException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/jpa/spi/NativeQueryConstructorTransformer.java","lineNumber":94,"sourceCode":"\t\t\t\tfinal var message = new StringBuilder();\n\t\t\t\tmessage.append( \"Result class\" )\n\t\t\t\t\t\t.append( \" must have exactly one constructor with \" )\n\t\t\t\t\t\t.append( elements.length )\n\t\t\t\t\t\t.append( \" parameters - found ['\" );\n\t\t\t\tboolean first = true;\n\t\t\t\tfor ( var c : resultClass.getDeclaredConstructors() ) {\n\t\t\t\t\tif ( c.getParameterCount() == elements.length ) {\n\t\t\t\t\t\tif ( !first ) {\n\t\t\t\t\t\t\tmessage.append( \"', '\" );\n\t\t\t\t\t\t}\n\t\t\t\t\t\tmessage.append( constructorSignature( c ) );\n\t\t\t\t\t\tfirst = false;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tmessage.append( \"'] in\" );\n\n\t\t\t\tthrow new InstantiationException( message.toString(), resultClass );\n\t\t\t}\n\t\t}\n\t\treturn constructor;\n\t}\n\n\t@Override\n\tpublic T transformTuple(Object[] tuple, String[] aliases) {\n\t\tfinal var ctor = constructor( tuple );\n\t\ttry {\n\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( '(' );","sourceCodeStart":76,"sourceCodeEnd":112,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/jpa/spi/NativeQueryConstructorTransformer.java#L76-L112","documentation":"Error \"Result class must have exactly one constructor with {} parameters - found ['{}'] in\" thrown in hibernate/hibernate-orm.","triggerScenarios":"Thrown at hibernate-core/src/main/java/org/hibernate/jpa/spi/NativeQueryConstructorTransformer.java:94 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Add a single constructor whose parameter count matches the query's selected columns, or adjust the SELECT list to match an existing constructor."],"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"}