{"record":{"id":"6ec199d4ef23a7d9","repo":"hibernate/hibernate-orm","slug":"no-result-found-for-query-getquerystring","errorCode":null,"errorMessage":"No result found for query [\" + getQueryString() + \"]","messagePattern":"No result found for query \\[\" \\+ getQueryString\\(\\) \\+ \"\\]","errorType":"exception","errorClass":"NoResultException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/procedure/internal/ProcedureCallImpl.java","lineNumber":1392,"sourceCode":"\t\t}\n\t}\n\n\t@Override\n\t@Nullable\n\tpublic <R1> R1 getSingleResult(@Nonnull jakarta.persistence.sql.ResultSetMapping<R1> resultSetMapping) {\n\t\tcheckNotClosed();\n\t\ttry {\n\t\t\tfinal var list = getResultList( resultSetMapping );\n\t\t\treturn list == null ? null : getSingleResult( list );\n\t\t}\n\t\tcatch ( HibernateException e ) {\n\t\t\tthrow getExceptionConverter().convert( e, getQueryOptions().getLockOptions() );\n\t\t}\n\t}\n\n\tprivate <R1> R1 getSingleResult(List<R1> results) {\n\t\tif ( results.isEmpty() ) {\n\t\t\tthrow new NoResultException( \"No result found for query [\" + getQueryString() + \"]\" );\n\t\t}\n\t\treturn uniqueElement( results );\n\t}\n\n\t@Override\n\t@Nullable\n\tpublic <R1> R1 getSingleResultOrNull(@Nonnull Class<R1> aClass) {\n\t\tcheckNotClosed();\n\t\ttry {\n\t\t\tfinal var list = getResultList( aClass );\n\t\t\treturn list == null ? null : uniqueElement( list );\n\t\t}\n\t\tcatch ( HibernateException e ) {\n\t\t\tthrow getExceptionConverter().convert( e, getQueryOptions().getLockOptions() );\n\t\t}\n\t}\n\n\t@Override","sourceCodeStart":1374,"sourceCodeEnd":1410,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/procedure/internal/ProcedureCallImpl.java#L1374-L1410","documentation":"JPA getSingleResult semantics for procedure calls: the outputs yielded an empty result list, so there is no single result to return, and jakarta NoResultException is mandatory. The faulty input is the expectation of at least one row; call getResultList() and handle emptiness, or use a single-result-or-null variant if available.","triggerScenarios":"A runtime precondition of the Hibernate API is violated.","commonSituations":"Occurs when application code or configuration does not satisfy the documented contract of the API being called.","solutions":["Use getResultList() and handle the empty case instead of getSingleResult().","Verify the procedure/query actually returns a row for the given parameters."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}