I am using spring-data-couchbase 4.1.1. I want to add a method in my repository method like following
public interface DomainRepository extends CouchbaseRepository<Domain, String> {
@Query(("SELECT isActive from #{#n1ql.bucket} "
+ "WHERE META().id = " + "\"#{#id}\" "))
Boolean isActive(@Param("id") String id);
}
But it throws ClassCastException for Domain to Boolean which is acceptable I believe.
Is there any other simple way to do it? I believe there was a findByN1QlProjection in older version of couchbaseTemplate, can't find it in this version though. But I rather not use couchbasetemplate directly or sub-document apis of couchbase sdk.
A similar older question How to fetch a field from document using n1ql with spring-data-couchbase