@Data
@Entity
@Table(name = "employees")
public class Employee extends Parent {
// other attributes
@ManyToMany(cascade = {CascadeType.ALL})
@JoinTable(
name = "employees_projects",
joinColumns = {@JoinColumn(name = "employee_id")},
inverseJoinColumns = {@JoinColumn(name = "project_id")}
)
Set<Project> projects = new HashSet<Project>();
}
@Data
@Entity
@Table(name = "projects")
public class Project extends Parent{
// other attributes
@ManyToMany(mappedBy = "projects", cascade = {CascadeType.ALL})
private Set<Employee> employees = new HashSet<Employee>();
}