私はJPAのツリー構造にSpringデータ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投影=すべて
私はルートドキュメントの最初の子のみを取得します。子供の子供ではありません。これは予測可能ですか?それとも別の方法がありますか?