{"record":{"id":"fdf76b9587f0c90a","repo":"hibernate/hibernate-orm","slug":"missing-instantiation-target-type","errorCode":null,"errorMessage":"Missing instantiation target type","messagePattern":"Missing instantiation target type","errorType":"exception","errorClass":"SyntaxException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/query/hql/internal/SemanticQueryBuilder.java","lineNumber":1542,"sourceCode":"\t\t\t\tthrow new SemanticException( \"Missing constructor for type '\" + typeName  + \"'\", query );\n\t\t\t}\n\t\t}\n\n\t\treturn dynamicInstantiation;\n\t}\n\n\t@Override\n\tpublic SqmDynamicInstantiation<?> visitInstantiationTarget(HqlParser.InstantiationTargetContext ctx) {\n\t\tif ( ctx.MAP() != null ) {\n\t\t\treturn forMapInstantiation( mapJavaType, nodeBuilder() );\n\t\t}\n\t\telse if ( ctx.LIST() != null ) {\n\t\t\treturn forListInstantiation( listJavaType, nodeBuilder() );\n\t\t}\n\t\telse {\n\t\t\tfinal var simplePath = ctx.simplePath();\n\t\t\tif ( simplePath == null ) {\n\t\t\t\tthrow new SyntaxException( \"Missing instantiation target type\" );\n\t\t\t}\n\t\t\tfinal String className = instantiationClassName( simplePath );\n\t\t\ttry {\n\t\t\t\treturn forClassInstantiation( resolveInstantiationTargetType( className ), nodeBuilder() );\n\t\t\t}\n\t\t\tcatch (ClassLoadingException e) {\n\t\t\t\tthrow new SemanticException( \"Could not resolve class '\" + className + \"' named for instantiation\", query );\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate String instantiationClassName(HqlParser.SimplePathContext ctx) {\n\t\tfinal String name = ctx.getText();\n\t\treturn expectedResultTypeName != null && expectedResultTypeShortName.equals( name )\n\t\t\t\t? expectedResultTypeName\n\t\t\t\t: name;\n\t}\n","sourceCodeStart":1524,"sourceCodeEnd":1560,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/query/hql/internal/SemanticQueryBuilder.java#L1524-L1560","documentation":"Error \"Missing instantiation target type\" thrown in hibernate/hibernate-orm.","triggerScenarios":"A dynamic instantiation (select new) target cannot be constructed.","commonSituations":"Using 'select new SomeClass(...)' where the class is missing or has no matching constructor.","solutions":["Specify a target type for the dynamic instantiation ('new com.foo.Dto(...)').","Check the query syntax of the select clause."],"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"}