diff --git a/src/main/java/com/tarento/upsmf/examsAndAdmissions/repository/StudentExamRegistrationRepository.java b/src/main/java/com/tarento/upsmf/examsAndAdmissions/repository/StudentExamRegistrationRepository.java index d9d376fb5281eb790890cb1fd49067c99170309d..9d36d710cc443e71aa3928e6b25c4d64fe73dd26 100644 --- a/src/main/java/com/tarento/upsmf/examsAndAdmissions/repository/StudentExamRegistrationRepository.java +++ b/src/main/java/com/tarento/upsmf/examsAndAdmissions/repository/StudentExamRegistrationRepository.java @@ -61,4 +61,6 @@ public interface StudentExamRegistrationRepository extends JpaRepository<Student StudentExamRegistration getByStudentId(Long id); StudentExamRegistration getByStudentIdAndExamCycleId(Long studentId, Long examCycleId); + + List<StudentExamRegistration> getByExamCycleIdAndStudentId(Long examCycleId, Long studentId); } diff --git a/src/main/java/com/tarento/upsmf/examsAndAdmissions/service/HallTicketService.java b/src/main/java/com/tarento/upsmf/examsAndAdmissions/service/HallTicketService.java index 60685a293df15e657bb4c6a2a73bdd00501cb066..a2a3b90b2576a7bf848f90896d63e8ee5dcfce37 100644 --- a/src/main/java/com/tarento/upsmf/examsAndAdmissions/service/HallTicketService.java +++ b/src/main/java/com/tarento/upsmf/examsAndAdmissions/service/HallTicketService.java @@ -700,15 +700,13 @@ public class HallTicketService { public ResponseDto getDetailsByStudentIdAndExamCycleId(Long studentId, Long examCycleId) { ResponseDto response = new ResponseDto(Constants.API_HALLTICKET_GET_DETAILS_BY_STUDENT_AND_EXAM_CYCLE); - Optional<StudentExamRegistration> optionalRegistration = - studentExamRegistrationRepository.findByStudentIdAndExamCycleId(studentId, examCycleId); + List<StudentExamRegistration> registrationList = studentExamRegistrationRepository.getByExamCycleIdAndStudentId(examCycleId, studentId); - if (!optionalRegistration.isPresent()) { + if (registrationList == null) { ResponseDto.setErrorResponse(response, "NOT_FOUND", "No data found for given student ID and exam cycle ID.", HttpStatus.NOT_FOUND); return response; } - - StudentExamRegistration registration = optionalRegistration.get(); + StudentExamRegistration registration = registrationList.get(0); Map<String, Object> formattedData = new HashMap<>();