title: How to return a boolean from a document using spring-data-couchbase with @Query
body: <p>I am using spring-data-couchbase 4.1.1. I want to add a method in my repository method like following</p>
  <pre><code>public interface DomainRepository extends CouchbaseRepository&lt;Domain, String&gt; {
  
  @Query((&quot;SELECT isActive from #{#n1ql.bucket}  &quot;
        + &quot;WHERE META().id = &quot; + &quot;\&quot;#{#id}\&quot; &quot;))
  Boolean isActive(@Param(&quot;id&quot;) String id);
  
  }
  
  </code></pre>
  <p>But it throws ClassCastException for Domain to Boolean which is acceptable I believe.</p>
  <p>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.</p>
  <p>A similar older question <a href="https://stackoverflow.com/questions/38478291/how-to-fetch-a-field-from-document-using-n1ql-with-spring-data-couchbase">How to fetch a field from document using n1ql with spring-data-couchbase</a></p>