Custom N1QL query in couchbase using spring boot JAVA




I was playing with couchbase using I am stuck with running custom N1QL queries.

I wrote this in repository

@Query(“SELECT l.created_on,l.is_public,l.list_id,l.list_name,l.type,l.user_id,META(u).id AS _ID, META(u).cas AS _CAS FROM lists USE INDEX(lists USING GSI) WHERE type=‘list’ AND user_name=$userName AND list_name=$listName”)
public Lists checkListName(@Param(“userName”) String userName, @Param(“listName”) String listName);

But I am getting this

Unable to retrieve enough metadata for N1QL to entity mapping, have you selected _ID and _CAS?

Is their another way or what should I do to run this query.



I see META(u).id AS _ID, what does u refer to in the query, shouldn’t it be META(lists).id


Thanks I was able to figure it out, what was wrong with my query.