I have a many-to-many table between Employees - SchoolDepartment EmployeeSchoolDepartment
But I could not manage to solve recursion between them. I could ignore the Set but i dont want to do it i want to show the list without recursion.
Here is the entity files :
Employee :
@Id
@Column(name="`UserId`",nullable=false)
private int userId;
@Column(name="`FirstName`",nullable=false)
private String firstName;
@Column(name="`LastName`",nullable=false)
private String lastName;
@Column(name="`NationalityId`",unique=true,nullable=false)
private String nationalityId;
@Column(name="`BirthOfDate`",nullable=false)
private Date birthOfDate;
@OneToOne(fetch = FetchType.LAZY)
@JoinColumn(name="`UserId`")
private User user;
@OneToMany(mappedBy="employee")
@JsonIgnore()
Set<EmployeeSchoolDepartment> employeeSchoolDepartments;
SchoolDepartment
@Id()
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
private int id;
@Column(name = "department",nullable = false)
private String department;
@ManyToOne()
@JoinColumn(name = "school_id")
private School school;
@OneToMany(mappedBy="schoolDepartment")
Set<EmployeeSchoolDepartment> employeeSchoolDepartments;
EmployeeSchoolDepartment
@EmbeddedId
EmployeeSchoolDepartmentId id;
@Column(name = "start_date")
private Date startDate;
@Column(name = "graduate_date")
private Date graduateDate;
@ManyToOne()
@MapsId("employee_id")
@JoinColumn(name="employee_id")
private Employee employee;
@ManyToOne()
@MapsId("school_deparment_id")
@JoinColumn(name="school_department_id")
private SchoolDepartment schoolDepartment;