Reputation: 23
I'm trying to project a single field in a document. I tried a couple of approaches - one mentioned here in this Spring data Couchbase doc and another mentioned in this question
All of it returns the same exception
org.springframework.data.couchbase.core.CouchbaseQueryExecutionException:
Unable to execute query due to the following n1ql errors: {"msg":"Ambiguous reference to field _class.","code":3000}
at org.springframework.data.couchbase.core.CouchbaseTemplate.findByN1QL(CouchbaseTemplate.java:458) ~[spring-data-couchbase-3.0.6.RELEASE.jar:3.0.6.RELEASE]
Below is the query that I am using and it runs as expected on the Query workbench
public interface ProjectRespository extends CouchbasePagingAndSortingRepository<Project, String> {
@Query("SELECT DISTINCT projectId where #{#n1ql.filter} AND serverTech = $1")
List<ProjectIdDTO> findByServerTech(@Param("serverTech") String serverTech);
ProjectIdDTO
is a DTO I have specifically defined to return a List of ProjectId's. Not sure what is that I am missing here.
Upvotes: 0
Views: 1759
Reputation: 23
Thanks @vsr @subhashni for pointing out. Trivial mistake. It was indeed the missing #{n1ql.bucket} that was causing the error.
The Ambiguous reference to field _class
should have prompted me to double-check the query.
Upvotes: 1