【发布时间】:2016-08-01 06:31:41
【问题描述】:
我有一个 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)
}
还有一个投影
@Projection(name = "all", types = Document.class)
public interface AllDocumentsProjection {
int getId();
String getText();
Set<Document> getChildren();
}
当我使用 url 发出 GET 请求时
localhost:8080/documents/1?projection=all
我只得到根文档的第一个孩子。不是孩子的孩子。这可能与预测?还是有别的办法?
【问题讨论】:
标签: jpa tree projection spring-data-rest hateoas