Spring Data Couchbase (2.x) Document Relation

不问归期 提交于 2019-12-13 07:29:07

问题


I want to ask about spring data couchbase 2.x

Can I refer a document in spring data couchbase like @DbRef annotation in spring data mongodb?


回答1:


we implemented our persistence with mongo initially and are in the mode of switching to couchbase. Doing so, we're finding that referencing is highly relying on DBRef from mongo to perform relationships. This should be abstracted away and implemented outside of the underlying implementation. Same goes for searching, indexing, and the like.

https://jira.spring.io/plugins/servlet/mobile#issue/DATAREST-326

Spring Data has an @Reference which indeed is evaluated by the metadata and @DBRef carries it for mongodb.

Example :

Author.java

@Document
public class Author {

    @Field
    private String name;
}

Book.java

@Document
public class Book {

    @Field
    private String title;

    @Reference
    private Author author;
}


Sample code for @Reference using simpledb https://github.com/3pillarlabs/spring-data-simpledb#reference



来源:https://stackoverflow.com/questions/40223333/spring-data-couchbase-2-x-document-relation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!