finditerable 转list_如何使用Spring Data CouchBase 'findAll(Iterable<ID>)'方法?

方高丽
2023-12-01

我正在尝试使用Spring-Data-Couchbase .

我想从findAll(Iterable)方法获取List . 我将“全部”视图设置为我的 生产环境 视图 .

但是,我遇到了例外 . 我如何使用findAll(Iterable)方法?

以下是示例代码和例外 .

文件类:

@Document

public class User {

@Id

private String id;

private String userSeq;

}

存储库类:

public interface UserRepository extends CouchbaseRepository {

}

服务类别:

//List get the Same result & exception.

Set friendSet = new HashSet();

friendSet.add("User8");

friendSet.add("User6");

userRepository.findAll(friendSet)

例外:

Caused by: java.util.concurrent.ExecutionException: OperationException: SERVER: bad_request Reason: invalid UTF-8 JSON: {{error,{2,"lexical error: invalid char in json text.\n"}},

"[User8, User6]"}

at com.couchbase.client.internal.HttpFuture.waitForAndCheckOperation(HttpFuture.java:98)

at com.couchbase.client.internal.HttpFuture.get(HttpFuture.java:82)

at com.couchbase.client.internal.HttpFuture.get(HttpFuture.java:72)

at com.couchbase.client.CouchbaseClient.query(CouchbaseClient.java:778)

... 66 more

Caused by: OperationException: SERVER: bad_request Reason: invalid UTF-8 JSON: {{error,{2,"lexical error: invalid char in json text.\n"}},

"[User8, User6]"}

at com.couchbase.client.protocol.views.NoDocsOperationImpl.parseError(NoDocsOperationImpl.java:110)

at com.couchbase.client.protocol.views.ViewOperationImpl.handleResponse(ViewOperationImpl.java:68)

at com.couchbase.client.http.HttpResponseCallback.completed(HttpResponseCallback.java:103)

at com.couchbase.client.http.HttpResponseCallback.completed(HttpResponseCallback.java:51)

at org.apache.http.concurrent.BasicFuture.completed(BasicFuture.java:115)

at org.apache.http.nio.protocol.HttpAsyncRequester$RequestExecutionCallback.completed(HttpAsyncRequester.java:376)

at org.apache.http.concurrent.BasicFuture.completed(BasicFuture.java:115)

at org.apache.http.nio.protocol.BasicAsyncClientExchangeHandler.responseCompleted(BasicAsyncClientExchangeHandler.java:179)

at org.apache.http.nio.protocol.HttpAsyncRequestExecutor.processResponse(HttpAsyncRequestExecutor.java:349)

at org.apache.http.nio.protocol.HttpAsyncRequestExecutor.inputReady(HttpAsyncRequestExecutor.java:236)

at org.apache.http.impl.nio.DefaultNHttpClientConnection.consumeInput(DefaultNHttpClientConnection.java:267)

at org.apache.http.impl.nio.DefaultHttpClientIODispatch.onInputReady(DefaultHttpClientIODispatch.java:165)

at org.apache.http.impl.nio.DefaultHttpClientIODispatch.onInputReady(DefaultHttpClientIODispatch.java:51)

at org.apache.http.impl.nio.reactor.AbstractIODispatch.inputReady(AbstractIODispatch.java:113)

at org.apache.http.impl.nio.reactor.BaseIOReactor.readable(BaseIOReactor.java:159)

at org.apache.http.impl.nio.reactor.AbstractIOReactor.processEvent(AbstractIOReactor.java:338)

at org.apache.http.impl.nio.reactor.AbstractIOReactor.processEvents(AbstractIOReactor.java:316)

at org.apache.http.impl.nio.reactor.AbstractIOReactor.execute(AbstractIOReactor.java:277)

at org.apache.http.impl.nio.reactor.BaseIOReactor.execute(BaseIOReactor.java:105)

at org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor$Worker.run(AbstractMultiworkerIOReactor.java:584)

... 1 more

 类似资料: