How to expose a complete tree structure with Spring Data REST and HATEOAS?
<p>I have a JPA tree structure</p>

<pre><code>@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&lt;Document&gt; children;

   (getters and setters)

}
</code></pre>

<p>and a projection</p>

<pre><code>@Projection(name = "all", types = Document.class)
public interface AllDocumentsProjection {

    int getId();
    String getText();
    Set&lt;Document&gt; getChildren();

}
</code></pre>

<p>When I make a GET request with url </p>

<p>localhost:8080/documents/1?projection=all</p>

<p>I only get the first children of the root document. Not children of the children. Is this possible with projections? Or is there an other way?</p>