Théo Le Lez c94d3654ce
All checks were successful
Format / formatting (push) Successful in 7s
Build / build (push) Successful in 31s
CI / build (push) Successful in 11s
fix: updating foreign keys when adding new entity to the db
2025-03-15 15:23:18 +01:00

111 lines
2.9 KiB
Java

package enseirb.myinpulse.model;
import jakarta.persistence.*;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
@Entity
@Table(name = "section_cell")
public class SectionCell {
@ManyToMany(mappedBy = "listSectionCell")
private final List<Appointment> listAppointment = new ArrayList<>();
@OneToMany(mappedBy = "sectionCellAnnotation", fetch = FetchType.LAZY, orphanRemoval = true)
private final List<Annotation> listAnnotation = new ArrayList<>();
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long idSectionCell;
@Column() private long sectionId;
private String contentSectionCell;
/*@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "idAdministrator")
private Administrator administratorSectionCell;*/
// should now be useless
private LocalDateTime modificationDate;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "idProject")
private Project projectSectionCell;
public SectionCell() {}
public SectionCell(
Long idSectionCell,
Long sectionId,
String contentSectionCell,
LocalDateTime modificationDate,
Project projectSectionCell) {
this.idSectionCell = idSectionCell;
this.sectionId = sectionId;
this.contentSectionCell = contentSectionCell;
this.modificationDate = modificationDate;
this.projectSectionCell = projectSectionCell;
}
public Long getIdSectionCell() {
return idSectionCell;
}
public void setIdSectionCell(Long idSectionCell) {
this.idSectionCell = idSectionCell;
}
public Long getSectionId() {
return sectionId;
}
public void setSectionId(Long sectionId) {
this.sectionId = sectionId;
}
public String getContentSectionCell() {
return contentSectionCell;
}
public void setContentSectionCell(String contentSectionCell) {
this.contentSectionCell = contentSectionCell;
}
public LocalDateTime getModificationDate() {
return modificationDate;
}
public void setModificationDate(LocalDateTime modificationDate) {
this.modificationDate = modificationDate;
}
public Project getProjectSectionCell() {
return projectSectionCell;
}
public List<Appointment> getAppointmentSectionCell() {
return listAppointment;
}
public void updateAppointmentSectionCell(Appointment appointment) {
listAppointment.add(appointment);
}
public List<Annotation> getListAnnotation() {
return listAnnotation;
}
public void updateListAnnotation(Annotation annotation) {
listAnnotation.add(annotation);
}
public void setSectionId(long sectionId) {
this.sectionId = sectionId;
}
public void setProjectSectionCell(Project projectSectionCell) {
this.projectSectionCell = projectSectionCell;
}
}