我正在使用Spring Data findAll(Iterable)方法从couchbase中检索信息 . 但是我看到无响应 .
我定义了下面列出的存储库:
public interface CustomerRepository extends CrudRepository<Customer, String> {
}
我通过传递有效的json来获取数据
Iterable<Customer> custIter=customerRepository.findAll(customerList);
视图定义如下:
function (doc, meta) {
if(doc._class=="com.customer.model.types.Customer" ){
emit(meta.id, doc);
}
}
编辑:
如果我在findAll调用之前的循环中进行findOne调用,则findAll调用将返回数据 .
2 回答
findAll基于视图,我认为这可能是由于查看索引延迟...您是否碰巧在执行此代码之前重新创建数据? IIRC此版本没有使用特定的过期标准,因此它应该默认为UPDATE_AFTER,它将在第一次查询后重新同步索引(对应于您在第一次查找时与第一次查询相对应的内容...)
有点晚了,但我只是因为@FuzzyAmi 's remark. Don' t发出
(null, null)
而有问题,因为findAll(Iterable<ID>)
方法依赖于KEYS而不是ID来查找文件 . 我有一个发出(null, null)
的视图,findAll(Iterable<ID>)
总是返回一个空列表 . 我认为这应该记录在spring-data-couchbase javadoc中 .Emit
(meta.id, null)
能够使用spring-data-couchbasefindAll(Iterable<ID>)
.@ simon-baslé:我认为应该更新文档 .