【发布时间】:2018-04-18 09:31:05
【问题描述】:
我对递归投影有疑问。
在 Spring Data Rest 中使用投影的最佳方法是什么?
我有下一个实体:Profile、Params 和 Chapters。
它们之间的关系如下:
-> 使用参数配置 ManyToMany。
-> 带有章节的参数 ManyToOne
我已经定义了我的个人预测并将其包含在我的存储库中,并带有 excerpt 属性,但是当我请求它们时,投影仅在第一级有效,在我的情况下,当我列出配置文件时,我看到的投影我申请了配置文件实体,但没有看到我在第二级为 param 实体定义的投影。
预测在这里:
@Projection(name = "profileProjection", types = Profile.class)
public interface ProfileProjection {
int getId();
List<Param> getParams();
}
@Projection(name = "paramProjection", types = Param.class)
public interface ParamProjection {
int getId();
Chapter getChapter();
List<Profile> getProfiles();
}
此外,当我只想查看第一级时,我会递归地查看与我的参数关联的配置文件。停止递归的最佳方法是什么?我尝试在这样的 url 中使用 projection param,但效果不佳。
....../parametros?projection=parametroProjection
是否可以在一个 url 中应用两个投影?
【问题讨论】:
标签: spring spring-data spring-data-jpa spring-data-rest