I’ve been in the industry for many years, however I am totally new to Spring and Couchbase. I think it’s great technology and would like to use the technologies for a project here in CA. I’ve set up the server, populated the buckets, fired up STS and pulled some sample code from github. Does anyone have some simple code that merely retreives a document from the beer-sample bucket using Spring? Most of the examples have been incomplete or I spend hours wrestling with Maven issues
Thank you so much,
great to hear you are trying out Couchbase and Spring Data
Unfortunately, using the
beer-sample bucket isn’t ideal for trying out Spring Data.
Here’s the thing: Spring Data needs metadata it generates in the content of the documents to correctly deserialize them from JSON. This is typically embodied in the
_class JSON attribute. Since
beer-sample is a generic-purpose Couchbase sample, this requirement isn’t reflected in the bucket’s contents.
You would probably be better off working from the default bucket and using Spring Data to both
save and retrieve your entities.
- the associated
findByAttendeesGreaterThanEqualis simple but interesting enough, for example)
PartyPopulatorListenerthat generates data (and uses the template’s
savemethod - template is one level of abstraction below repositories -)
- here is an example of a test that uses the repository
Be sure to also read the documentation to familiarize yourself with all these abstractions and how the couchbase spring data implementation covers them.
Thank you for the advice Simon Yes, this is just the thing I am looking for; I’ll start using the default bucket then and of course read the documentation. I come from a relational database background and I think this stuff is exciting
Awesome! Don’t hesitate if you need more information or things start to feel too strange
I have imported the spring-data-couchbase code into STS and I am having an odd problem. When I attempt to build the workspace, I get an error:
internal compiler error: java.lang.NullPointerException at org.eclipse.jdt.internal.compiler.ast.ForeachStatement.resolve(ForeachStatement.java:429) StringN1qlBasedQuery.java /spring-data-couchbase/src/main/java/org/springframework/data/couchbase/repository/query line 0 Java Problem.
It appears the Java Builder in the IDE is having problems digesting StringN1qlBasedQuery.java. The error truly does appear right before the comment section of the class source. Frankly, I’ve not ever seen an error like this. However I am able to build and install without difficulty using Maven. I have tried various JDK compilers without success. I have also tried switching the STS workspace in the event the metadata had been corrupted; no dice. Any ideas? btw: I am using Version: 3.7.3.RELEASE
Build Id: 201602250940
Platform: Eclipse Mars.2 (4.5.2)
I checked the log file and the following was of interest:
!ENTRY org.eclipse.jdt.ui 4 2 2016-04-14 22:52:47.976
!MESSAGE Problems occurred when invoking code from plug-in: “org.eclipse.jdt.ui”.
Java Model Exception: java.lang.NullPointerException
Looks like it’s been fixed in Eclipse 4.6 Neon, and there are 4.6-based builds of STS available: https://spring.io/tools/sts/all
Great Simon! Thank you, I am downloading the new verison