{"record":{"id":"cbce4e66e950a261","repo":"hibernate/hibernate-orm","slug":"empty-selections-passed-to-criteria-query-typed-as","errorCode":null,"errorMessage":"Empty selections passed to criteria query typed as Object","messagePattern":"Empty selections passed to criteria query typed as Object","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/query/sqm/tree/spi/select/AbstractSqmSelectQuery.java","lineNumber":525,"sourceCode":"\t\treturn object instanceof AbstractSqmSelectQuery<?> that\n\t\t\t&& Objects.equals( this.resultType, that.resultType ) // for performance!\n\t\t\t&& this.sqmQueryPart.isCompatible( that.sqmQueryPart )\n\t\t\t&& SqmCacheable.areCompatible( this.cteStatements, that.cteStatements );\n\t}\n\n\t@Override\n\tpublic int cacheHashCode() {\n\t\tint result = SqmCacheable.cacheHashCode( cteStatements );\n\t\tresult = 31 * result + sqmQueryPart.cacheHashCode();\n\t\treturn result;\n\t}\n\n\t@SuppressWarnings(\"unchecked\")\n\tprotected Selection<? extends T> getResultSelection(Selection<?>[] selections) {\n\t\tfinal var resultType = getResultType();\n\t\tif ( resultType == Object.class ) {\n\t\t\treturn switch ( selections.length ) {\n\t\t\t\tcase 0 -> throw new IllegalArgumentException( \"Empty selections passed to criteria query typed as Object\" );\n\t\t\t\tcase 1 -> (Selection<? extends T>) selections[0];\n\t\t\t\tdefault -> (Selection<? extends T>) nodeBuilder().array( selections );\n\t\t\t};\n\t\t}\n\t\telse if ( Tuple.class.isAssignableFrom( resultType ) ) {\n\t\t\treturn (Selection<? extends T>) nodeBuilder().tuple( selections );\n\t\t}\n\t\telse if ( resultType.isArray() ) {\n\t\t\treturn nodeBuilder().array( resultType, selections );\n\t\t}\n\t\telse {\n\t\t\treturn nodeBuilder().construct( resultType, selections );\n\t\t}\n\t}\n\n}\n","sourceCodeStart":507,"sourceCodeEnd":542,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/spi/select/AbstractSqmSelectQuery.java#L507-L542","documentation":"Error \"Empty selections passed to criteria query typed as Object\" thrown in hibernate/hibernate-orm.","triggerScenarios":"multiselect() is called with an empty selection list on a CriteriaQuery typed as Object, so no result shape can be inferred.","commonSituations":"Passing an empty or conditionally-built selection list that ended up empty; provide at least one selection or use Object[].class.","solutions":["Provide at least one selection to the criteria query (e.g. criteria.select(root) or criteria.multiselect(...)).","If you intend a compound result, declare the query as Tuple/Object[] instead of Object and pass multiple selections.","Check code paths that build the selection list dynamically and make sure the list is not empty before calling multiselect."],"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"}