鉴于这3个实体:
@Entity
class Department{
Set
我想为部门创建一个投影,让所有部门都有员工和国籍.我所取得的成就是让所有部门与员工一起使用:
@Projection(name = "fullDepartment",types = { Department.class })
public interface DepartmentsProjection {
Set
最佳答案
一种方法是为嵌套对象创建一个Projection,然后在更全局的对象中使用此投影.因此,根据您的问题,您可以为国籍创建一个投影,然后为部门创建一个投影来捕获国籍的投影,最后是另一个投影以获得部门的实体.
原文链接:https://www.f2er.com/spring/431590.html@Projection(name = "NationalityProjection",types = { Nationality.class })
public interface NationalityProjection{
// getters of all attributes you want to project
}
@Projection(name = "EmployeeProjection",types = { Employee.class })
public interface EmployeeProjection{
NationalityProjection getNationality();
}
@Projection(name = "DepartmentProjection",types = { Department.class })
public interface DepartmentProjection{
Set
希望能帮助到你!