Spring Data Couchbase(2.x)文档关系 [英] Spring Data Couchbase (2.x) Document Relation
问题描述
我想问一下关于Spring data benchbase 2.x
I want to ask about spring data couchbase 2.x
我可以在Spring数据沙发基础上引用文档,例如Spring数据mongodb中的@DbRef
注释吗?
Can I refer a document in spring data couchbase like @DbRef
annotation in spring data mongodb?
推荐答案
我们最初对mongo实施了持久性,并且处于切换到沙发床的模式.这样做,我们发现引用高度依赖于mongo的DBRef来执行关系.应该将其抽象出来并在基础实现之外实现.搜索,索引等也是如此.
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有一个@Reference,它确实是由元数据评估的,而@DBRef则将其用于mongodb.
Spring Data has an @Reference which indeed is evaluated by the metadata and @DBRef carries it for mongodb.
示例:
Author.java
Author.java
@Document
public class Author {
@Field
private String name;
}
Book.java
Book.java
@Document
public class Book {
@Field
private String title;
@Reference
private Author author;
}
使用simpledb https://github.com/3pillarlabs/spring-data的@Reference
的示例代码-simpledb#reference
Sample code for @Reference
using simpledb https://github.com/3pillarlabs/spring-data-simpledb#reference
这篇关于Spring Data Couchbase(2.x)文档关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!