diff --git a/server/src/main/java/ru/mskobaro/tdms/business/service/ParticipantService.java b/server/src/main/java/ru/mskobaro/tdms/business/service/ParticipantService.java index 825cb37..425bf77 100644 --- a/server/src/main/java/ru/mskobaro/tdms/business/service/ParticipantService.java +++ b/server/src/main/java/ru/mskobaro/tdms/business/service/ParticipantService.java @@ -115,6 +115,10 @@ public class ParticipantService { С уважением, администрация. """.formatted(participant.getFullName(), participant.getUser().getUsername(), participantSaveDTO.getUserData().getPassword())); + if (studentData != null) { + studentData.setParticipant(saved); + } + if (studentData != null && studentData.getGroup() != null) { List defenses = entityManager.createQuery("select distinct d from Defense d inner join fetch d.groups g where g.id = :id", Defense.class) .setParameter("id", studentData.getGroup().getId()) @@ -248,7 +252,6 @@ public class ParticipantService { studentData.setMarks3(participantSaveDTO.getStudentData().getMarks3()); studentData = studentDataRepository.save(studentData); - studentData.setParticipant(participant); if (participantSaveDTO.getStudentData().getGroupId() != null) { Group group = groupRepository.findByIdThrow(participantSaveDTO.getStudentData().getGroupId()); diff --git a/server/src/main/resources/db/migration/V00000__Initial_schema.sql b/server/src/main/resources/db/migration/V00000__Initial_schema.sql index adb257d..63c10af 100644 --- a/server/src/main/resources/db/migration/V00000__Initial_schema.sql +++ b/server/src/main/resources/db/migration/V00000__Initial_schema.sql @@ -229,9 +229,6 @@ ALTER TABLE participant_role ALTER TABLE participant_role ADD CONSTRAINT FK_PARROL_ON_ROLE FOREIGN KEY (role_id) REFERENCES role (id) ON DELETE CASCADE ON UPDATE CASCADE; -ALTER TABLE student_data - ADD CONSTRAINT UC_STUDENT_DATA_PARTIC UNIQUE (partic_id); - ALTER TABLE student_data ADD CONSTRAINT FK_STUDENT_DATA_ON_ADVISER_TEACHER_PARTIC FOREIGN KEY (adviser_teacher_partic_id) REFERENCES participant (id) ON DELETE SET NULL ON UPDATE CASCADE;