Java Spring 投影内投影 [英] Java Spring projection inside projection

查看:69
本文介绍了Java Spring 投影内投影的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以使用投影并在某些相关对象中使用它自己的投影?

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

例如,有Exam,即有List.我想请求一份考试列表(我有一个 @projection),但我想定义要为每个相关 Question 检索的属性/p>

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

推荐答案

如果我理解正确,您想使用 Projection 作为 Projection 的子项.如果是这样,是的,你可以.您可以创建一个 QuestionProjection 并在 ExamProjection 中使用.

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.

示例:

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

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

    // Other Getters
}

这篇关于Java Spring 投影内投影的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆