How to expose a complete tree structure with Spring Data REST and HATEOAS?

拈花ヽ惹草 提交于 2019-12-03 08:37:52
@Projection(name = "all", types = Document.class)
public interface AllDocumentsProjection {

    int getId();
    String getText();
    Set<AllDocumentsProjection> getChildren();

}

This works perfect for me.

I'm almost certain there is no way to recursively embed resources via projections. Only other thing I think of is to handle this logic manually in the controller :/

Try excerpts.

You should add to your repository definition the excerptProjection field like below:

@RepositoryRestResource(excerptProjection = AllDocumentsProjection.class)
interface DocumentRepository extends CrudRepository<Document, Integer> {}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!