Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/jpa/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring-JPA&Couchbase-com.Couchbase.client.java.error.ViewDoesNotExistException:View cat/all不存在_Java_Jpa_Couchbase_Spring Data Couchbase - Fatal编程技术网

Spring-JPA&Couchbase-com.Couchbase.client.java.error.ViewDoesNotExistException:View cat/all不存在

Spring-JPA&Couchbase-com.Couchbase.client.java.error.ViewDoesNotExistException:View cat/all不存在,java,jpa,couchbase,spring-data-couchbase,Java,Jpa,Couchbase,Spring Data Couchbase,我的Spring boot应用程序正在尝试从Couchbasebucket获取Cat类型的所有文档 有一个索引: CREATE INDEX cats_idx ON `cats`(_class) WHERE _class = 'com.example.Cat' 还有一个存储库类: SpringDataSDK的当前实现仍然在内部使用视图,因为findAll和removeAll视图等方法在SDK版本3.0上不再使用。因此,您可以为该文档类型创建一个视图,也可以自己实现一个新的findAll方法: @

我的Spring boot应用程序正在尝试从Couchbasebucket获取Cat类型的所有文档

有一个索引:

CREATE INDEX cats_idx ON `cats`(_class) WHERE _class = 'com.example.Cat'
还有一个存储库类:


SpringDataSDK的当前实现仍然在内部使用视图,因为findAll和removeAll视图等方法在SDK版本3.0上不再使用。因此,您可以为该文档类型创建一个视图,也可以自己实现一个新的findAll方法:

@Query("#{#n1ql.selectEntity} where #{#n1ql.filter} ")
List<Cat> all();
该方法应使用您的cats\u idx


PS:cats_idx不是最优的,您不应该在索引中存储_class属性。

我在使用coach base时也遇到了同样的问题,如果执行了.findAll方法。因此,我在repository类中给出了以下注释

@N1qlPrimaryIndexed
@ViewIndexed(designDoc = "product",viewName = "all")
public interface ProductRepository extends CouchbaseRepository<Product,Integer> {
}

上面的方法对我很有效。

你能详细说明一下索引的问题吗?在索引中存储_类意味着,假设你有几百万只猫,你基本上会有几百万次相同的字符串com.example.Cat。您的索引应该按_类过滤,但存储更有用的属性:在catsage、name、race上创建cats_idx,其中_class='com.example.Cat'。我在这里写了这个教程,您好,我得到的错误与问题中提到的相同。我尝试了使用查询注释的解决方案,但再次出现相同的错误。我的疑问是我没有正确地实施解决方案。我正在做下面的事情,如果我遗漏了什么,请纠正我@RequestMapping value=/all,method=RequestMethod.GET@Queryselect*from bucketname public Iterable getAllCats{Iterable all=catRepository.findAll;return all;}
Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request 
processing failed; nested exception is 
org.springframework.dao.InvalidDataAccessResourceUsageException: View cat/all does not exist.; 
nested exception is com.couchbase.client.java.error.ViewDoesNotExistException: View cat/all does not 
exist.] with root cause 
rx.exceptions.OnErrorThrowable$OnNextValue: OnError while emitting onNext value: com.couchbase.client.java.document.json.JsonObject.class
at rx.exceptions.OnErrorThrowable.addValueAsLastCause(OnErrorThrowable.java:118)
at rx.internal.operators.OnSubscribeMap$MapSubscriber.onNext(OnSubscribeMap.java:73)
at rx.internal.operators.OnSubscribeMap$MapSubscriber.onNext(OnSubscribeMap.java:77)
at rx.internal.producers.SingleProducer.request(SingleProducer.java:65)
at rx.Subscriber.setProducer(Subscriber.java:211)
at rx.internal.operators.OnSubscribeMap$MapSubscriber.setProducer(OnSubscribeMap.java:102)
at rx.internal.operators.OnSubscribeMap$MapSubscriber.setProducer(OnSubscribeMap.java:102)
at rx.internal.operators.OperatorSingle$ParentSubscriber.onCompleted(OperatorSingle.java:113)
at rx.internal.operators.OperatorObserveOn$ObserveOnSubscriber.checkTerminated(OperatorObserveOn.java:281)
at rx.internal.operators.OperatorObserveOn$ObserveOnSubscriber.call(OperatorObserveOn.java:216)
at rx.internal.schedulers.ScheduledAction.run(ScheduledAction.java:55)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run$$$capture(FutureTask.java:266)
at java.util.concurrent.FutureTask.run(FutureTask.java)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
@Query("#{#n1ql.selectEntity} where #{#n1ql.filter} ")
List<Cat> all();
@N1qlPrimaryIndexed
@ViewIndexed(designDoc = "product",viewName = "all")
public interface ProductRepository extends CouchbaseRepository<Product,Integer> {
}