diff --git a/src/main/java/de/hmmh/pmt/ApiController.java b/src/main/java/de/hmmh/pmt/ApiController.java index e7e702e..26fc2b7 100644 --- a/src/main/java/de/hmmh/pmt/ApiController.java +++ b/src/main/java/de/hmmh/pmt/ApiController.java @@ -137,7 +137,7 @@ public class ApiController implements DefaultApi { Allocation allocation = new Allocation(); allocation.setEmployeeId(employee.getId()); allocation.setRole(body.getQualificationId()); - allocation.setProjectId(project.getId()); + allocation.setProject(project); allocationRepository.save(allocation); return new ResponseEntity<>(HttpStatus.NO_CONTENT); diff --git a/src/main/java/de/hmmh/pmt/db/Allocation.java b/src/main/java/de/hmmh/pmt/db/Allocation.java index 5ed7008..3f2ae9b 100644 --- a/src/main/java/de/hmmh/pmt/db/Allocation.java +++ b/src/main/java/de/hmmh/pmt/db/Allocation.java @@ -2,10 +2,7 @@ package de.hmmh.pmt.db; import jakarta.persistence.*; import jakarta.validation.constraints.NotNull; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; +import lombok.*; @NoArgsConstructor @AllArgsConstructor @@ -15,15 +12,23 @@ import lombok.Setter; @IdClass(AllocationId.class) @Table(name = "allocation") public class Allocation { - @Id - private Long projectId; - @ManyToOne - @JoinColumn(name = "projectId", insertable = false, updatable = false) - private Project project; + @Id + @Setter(AccessLevel.NONE) + private Long projectId; + + @ManyToOne + @JoinColumn(name = "allocation_project", referencedColumnName = "id", insertable = false, updatable = false) + private Project project; + @Id private Long employeeId; @NotNull private Long role; // This is a QualificationId + + public void setProject(Project project) { + this.project = project; + this.projectId = project.getId(); + } }