考虑到这三个实体:
@Entity
class Department{
Set<Employee> employees;
Set<Employee> getEmployees(){
return this.employees;
};
}
@Entity
class Employee{
Nationality nationality;
Nationality getNationality(){
this.nationality;
}
}
@Entity
class Nationality{
}
我想为部门
创建一个投影,以返回所有部门及其雇员和国籍。我已经实现的是使用以下语句返回所有带有员工的部门:
@Projection(name = "fullDepartment", types = { Department.class })
public interface DepartmentsProjection {
Set<Employee> getEmployees();
}
@RepositoryRestResource(collectionResourceRel = "department", path = "departments")
public interface DepartmentRepository extends JpaRepository<Department, Long> {
}