Nor*_*aft 5 tree jpa projection hateoas spring-data-rest
我有一个 JPA 树结构
@Entity
public class Document {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private int id;
private String text;
@ManyToOne
@JoinColumn(name = "parent")
Document parent;
@OneToMany(mappedBy = "parent", fetch = FetchType.EAGER)
Set<Document> children;
(getters and setters)
}
Run Code Online (Sandbox Code Playgroud)
和一个投影
@Projection(name = "all", types = Document.class)
public interface AllDocumentsProjection {
int getId();
String getText();
Set<Document> getChildren();
}
Run Code Online (Sandbox Code Playgroud)
当我使用 url 发出 GET 请求时
本地主机:8080/documents/1?projection=all
我只获取根文档的第一个子级。不是孩子的孩子。这可以通过投影实现吗?或者还有其他方法吗?
| 归档时间: |
|
| 查看次数: |
3368 次 |
| 最近记录: |