Java Spring projection inside projection

梦想与她 提交于 2020-01-06 06:36:32

问题


Is it possible to use a projection and in some related object use it's own projection?

For example, a have Exam, that has List<Question>. I'd like to request a list of exams (wich I have a @projection), but I'd like to define the attributes to be retreived for each related Question


回答1:


If I understand correctly you want to use Projection as children of Projection. If it is the case, yes, you can. You can create a QuestionProjection and use inside the ExamProjection.

Example:

@Projection(name = "questionProjection", types = { Question.class }) 
public interface QuestionProjection {
    // Getters
}

@Projection(name = "examProjection", types = { Exam.class }) 
public interface ExamProjection {
    List<QuestionProjection> getQuestionList();

    // Other Getters
}


来源:https://stackoverflow.com/questions/48995744/java-spring-projection-inside-projection

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!