【发布时间】:2016-12-18 19:08:34
【问题描述】:
鉴于这 3 个实体:
@Entity
class Department{
Set<Employee> employees;
Set<Employee> getEmployees(){
return this.employees;
};
}
@Entity
class Employee{
Nationality nationality;
Nationality getNationality(){
this.nationality;
}
}
@Entity
class Nationality{
}
我想为 Department 创建一个投影,返回所有部门及其员工和国籍。我所取得的成就是让所有部门及其员工使用:
@Projection(name = "fullDepartment", types = { Department.class })
public interface DepartmentsProjection {
Set<Employee> getEmployees();
}
@RepositoryRestResource(collectionResourceRel = "department", path = "departments")
public interface DepartmentRepository extends JpaRepository<Department, Long> {
}
【问题讨论】:
-
你解决了这个问题吗?
标签: java spring projection spring-data-rest