{"record":{"id":"75b7e87a370be603","repo":"quarkusio/quarkus","slug":"no-country-found-with-id","errorCode":null,"errorMessage":"No Country found with id =","messagePattern":"No Country found with id =","errorType":"exception","errorClass":"NoResultException","httpStatus":null,"severity":"error","filePath":"integration-tests/spring-data-jpa/src/main/java/io/quarkus/it/spring/data/jpa/CountryResource.java","lineNumber":67,"sourceCode":"    @GET\n    @Path(\"/new/{name}/{iso3}\")\n    @Produces(\"application/json\")\n    public Country newCountry(@PathParam(\"name\") String name, @PathParam(\"iso3\") String iso3) {\n        countryRepository.flush();\n        return countryRepository.saveAndFlush(new Country(name, iso3));\n    }\n\n    @GET\n    @Path(\"/editIso3/{id}/{iso3}\")\n    @Produces(\"application/json\")\n    public Country editIso3(@PathParam(\"id\") Long id, @PathParam(\"iso3\") String iso3) {\n        Optional<Country> optional = countryRepository.findById(id);\n        if (optional.isPresent()) {\n            Country country = optional.get();\n            country.setIso3(iso3);\n            return countryRepository.save(country);\n        } else {\n            throw new NoResultException(\"No Country found with id =\" + id);\n        }\n    }\n\n    @GET\n    @Path(\"/getOne/{id}\")\n    @Produces(\"application/json\")\n    public Country getOne(@PathParam(\"id\") Long id) {\n        return countryRepository.getOne(id);\n    }\n\n    @DELETE\n    @Path(\"/\")\n    public void deleteAllInBatch() {\n        this.countryRepository.deleteAllInBatch();\n    }\n}\n","sourceCodeStart":49,"sourceCodeEnd":84,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/integration-tests/spring-data-jpa/src/main/java/io/quarkus/it/spring/data/jpa/CountryResource.java#L49-L84","documentation":"CountryResource.editIso3 looks up a Country by id via countryRepository.findById; when the Optional is empty it throws javax.persistence.NoResultException('No Country found with id =' + id). This emulates Spring Data's getOne/getReference behavior where updating a non-existent row raises NoResultException.","triggerScenarios":"PUT/POST to the edit-iso3 endpoint with an id that has no corresponding row in the Country table.","commonSituations":"Stale client holding an id deleted elsewhere; test fixtures not seeded before update calls; integer-vs-string id mismatches in path parameters.","solutions":["Verify the Country id exists (GET the resource or check the DB) before editing","Handle NoResultException with an ExceptionMapper returning 404 Not Found","Use PUT semantics that create-or-update (upsert) if that matches your contract"],"exampleFix":"// before\n} else {\n    throw new NoResultException(\"No Country found with id =\" + id);\n}\n// after\n} else {\n    return Response.status(Response.Status.NOT_FOUND)\n        .entity(\"No Country found with id \" + id).build();\n}","handlingStrategy":"validation","validationCode":"boolean exists = countryRepository.findById(id).isPresent();\nif (!exists) {\n    // surface 404 before attempting editIso3\n}\n","typeGuard":null,"tryCatchPattern":"try {\n    countryResource.editIso3(id, iso3);\n} catch (NoResultException e) {\n    // handle as 404: entity with given id does not exist\n}","preventionTips":["Confirm ids exist (fresh fetch, not cached client state) before updates","Register an ExceptionMapper turning NoResultException into HTTP 404","Seed fixtures before update calls in tests"],"tags":["jpa","spring-data","no-result","rest"],"backgroundTag":"entity-not-found","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}