Skip to content
Advertisement

Simple Spring Data Couchbase Find Query Not Working

I’m new to Couchbase and Spring Data Couchbase and am having issues getting a simple find query to work. I am running the community edition of couchbase (version 6.6.0), have the latest version of Spring Data Couchbase, and have created a small spring boot app to query from a new bucket I created. I am able to connect to the database ok, but none of the find queries I am using return any data. I have gone into the bucket and added a few indexes, but that didn’t seem to help either. I am hoping it is just something small that I am missing.

Here is my code…

Config

JavaScript

Model

JavaScript

Repository

JavaScript

Main code that runs on app startup. I never seem to be getting data back, even though I have a few documents in my bucket.

JavaScript

pom.xml

JavaScript

Advertisement

Answer

OK, I figured out the issue. I was manually inserting data via the Admin console, and I didn’t realize that you have to add an _class attribute to your documents. When Spring Data Couchbase generates its queries, they will look something like this:

JavaScript

And it won’t find any data if the _class attribute is missing (unless there is some property setting or something that lets you get around this).

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement