Filter by dates in all levels of mapping Association hibernate JPA

252 views Asked by At

I have multiple level of associated tables and their entities as below

Entity Department which has list of associated EmployeeDepAssoc

@Entity
public class Department
{
....
@OneToMany
List<EmployeeDepAssoc> employeeAssoc;
}

Entity EmployeeDepAssoc contains department and employee association and their validity period (start date and end date)

public class EmployeeDepAssoc
{
....
@JsonIgnore
@ManyToOne
Department department;

@OneToOne
Employee employee;

Date startDate;

Date endDate;

}

Entity Employee which has again list of associated PayStructure

@Entity
public class Employee
{
....
@OneToMany
List<PayStructure> payStructures;
}

Entity PayStructure contains employee and payStructure association and their validity period (start date and end date)

@Entity
public class PayStructure
{
....
@JsonIgnore
@ManyToOne
Department Employee;

Double salary;

Date startDate;

Date endDate;
}

When user requests for list of departments I have to give only data which is valid by user given date / current date in all levels.(ie. I have to filter by start date and end date in all levels). What is the way for this in Spring Boot JPA environment

Note: I just avoided some annotations like @JoinColumn here in this post. But I am using that in my code

0

There are 0 answers