diff --git a/src/main/java/com/tarento/upsmf/examsAndAdmissions/model/ExamCenter.java b/src/main/java/com/tarento/upsmf/examsAndAdmissions/model/ExamCenter.java index 65ba6b860c63b2a644984ad7b47943ca7dfc45f7..e4252416a329f77dc433abc72b27c91d9b7a3fd2 100644 --- a/src/main/java/com/tarento/upsmf/examsAndAdmissions/model/ExamCenter.java +++ b/src/main/java/com/tarento/upsmf/examsAndAdmissions/model/ExamCenter.java @@ -1,5 +1,6 @@ package com.tarento.upsmf.examsAndAdmissions.model; +import com.fasterxml.jackson.annotation.JsonIgnore; import com.tarento.upsmf.examsAndAdmissions.enums.ApprovalStatus; import lombok.*; @@ -43,6 +44,16 @@ public class ExamCenter { private Boolean alternateExamCenterAssigned = false; @OneToOne @JoinColumn(name = "alternate_exam_center_id") +// @JsonIgnore // Ignore this field during JSON serialization private ExamCenter alternateExamCenter; + @Override + public String toString() { + return "ExamCenter{" + + "id=" + id + + ", name='" + name + '\'' + + // ... (other fields) + ", alternateExamCenter=" + (alternateExamCenter != null ? alternateExamCenter.getId() : null) + // Handle alternateExamCenter to break the cyclic reference + '}'; + } } diff --git a/src/main/java/com/tarento/upsmf/examsAndAdmissions/service/ExamCenterService.java b/src/main/java/com/tarento/upsmf/examsAndAdmissions/service/ExamCenterService.java index d6fbbc48bd43d348cb59b2a9860ad15e19734c51..6c194131f5906b08457a34c00be59a9c887b590f 100644 --- a/src/main/java/com/tarento/upsmf/examsAndAdmissions/service/ExamCenterService.java +++ b/src/main/java/com/tarento/upsmf/examsAndAdmissions/service/ExamCenterService.java @@ -78,13 +78,13 @@ public class ExamCenterService { // Set the alternate exam center for the unverified exam center unverifiedExamCenter.setAlternateExamCenter(alternateExamCenter); unverifiedExamCenter.setAlternateExamCenterAssigned(true); - examCenterRepository.save(unverifiedExamCenter); + unverifiedExamCenter = examCenterRepository.save(unverifiedExamCenter); // Save the updated registrations List<StudentExamRegistration> updatedRegistrations = studentExamRegistrationRepository.saveAll(affectedRegistrations); response.put("message", "Alternate Exam Center assigned successfully."); - response.put(Constants.RESPONSE, updatedRegistrations); + response.put(Constants.RESPONSE, unverifiedExamCenter); response.setResponseCode(HttpStatus.OK); } } catch (EntityNotFoundException e) {