我有一个JPA树结构如何使用Spring Data REST和HATEOAS公开一个完整的树结构?
@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请求:8080 /文件/ 1的投影=所有
我只获取根文档的第一个孩子。不是孩子的孩子。这可能与预测?还是有其他方法?