package kr.wisestone.owl.domain; import javax.persistence.*; import java.io.Serializable; import java.util.HashSet; import java.util.Set; @Entity public class Department extends BaseEntity implements Serializable { private static final long serialVersionUID = 1L; @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; private String departmentName; private String departmentDescription; @OneToMany(mappedBy = "department", cascade = {CascadeType.ALL}, orphanRemoval = true) private Set projectRoleDepartments = new HashSet(); public Department() { } public Long getId() { return id; } public void setId(Long id) { this.id = id; } public String getDepartmentName() { return departmentName; } public void setDepartmentName(String departmentName) { this.departmentName = departmentName; } public String getDepartmentDescription() { return departmentDescription; } public void setDepartmentDescription(String departmentDescription) { this.departmentDescription = departmentDescription; } public void addProjectRole(ProjectRole projectRole) { if (this.projectRoleDepartments == null) { this.projectRoleDepartments = new HashSet<>(); } ProjectRoleDepartment projectRoleDepartment = new ProjectRoleDepartment(projectRole, this); this.projectRoleDepartments.add(projectRoleDepartment); } }