Skip to content

ADD: Get student by id method. - #2

Open
Icd-Kohi wants to merge 4 commits into
mdtalalwasim:mainfrom
Icd-Kohi:main
Open

ADD: Get student by id method.#2
Icd-Kohi wants to merge 4 commits into
mdtalalwasim:mainfrom
Icd-Kohi:main

Conversation

@Icd-Kohi

@Icd-Kohi Icd-Kohi commented Jul 20, 2026

Copy link
Copy Markdown
  1. Implement get student by id method.
  2. Address non existent id requests.
  3. Delete and fix typos, blank lines and redundant parameter.

Context

Having a the possibility to request the student by its id is useful and it further enhance the API usability.
After implementing a new endpoint and method, it was necessary to handle the exception of a non existent student id request.

Changes in the codebase

controller/StudentController.java, entity/Student.java, repository/StudentRepository.java, service/StudentService.java and service/StudentServiceImpl.java files were modified.

New implementation of StudentNotFoundException and GlobalExceptionHandler were added in exception/.

Aditional information

Response of requesting a non existent student:

{
  "instance": "/api/getStudent/3",
  "status": 404,
  "title": "Student not found.",
  "Student id: ": 3
}

Response of requesting a existent student:

{
  "address": "road one",
  "email": "mary@gmail.com",
  "id": 4,
  "name": "mary"
}

Icd-Kohi added 4 commits July 20, 2026 04:04
Remove unused `Optional` import. Alter
`@PutMapping("/editStudents/{id}")` to
`@PutMapping("/editStudent/{id}")`. Delete redundant annotation argument
`@PathVariable("id") long id` to `@PathVariable long id`.
Implement `StudentNotFoundException` if a non existant user id request
is made. Implement helper exception handler `GlobalExceptionHandler`.
@Icd-Kohi Icd-Kohi changed the title ADD: Get student by id method. Learning PR. ADD: Get student by id method. Jul 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant