spring-projects / spring-projects/spring-data-couchbase

document the more common use case of SELECT based custom repo method [DATACOUCH-280]

Open
#592 0 comments 0 reactions 1 assignee View on GitHub

@davidkelly is already working on this.

Since Dec 31, 2020.

type: documentation type: enhancement
Dominant language
Java
Stars
284
Forks
197
PR merge metrics
No merged PRs in 30d

Description

Simon Baslé opened DATACOUCH-280 and commented

The current snippet for creating a custom repository method implementation uses a count query and the template's older "projection" feature (NOT the spring-data-commons projections).

This is not necessarily the most straightforward use case, and it could be useful to expose both that one and a more common SELECT use case, where step 8 is more complicated to figure out:

// your own WHERE criteria:
Expression where = x("firstName = $1 and lastName = $2");

Statement statement =
    //this will produce the adequate SELECT..FROM.. clause:
    N1qlUtils.createSelectFromForEntity(template.getCouchbaseBucket().name())
    //use the DSL to continue to the WHERE clause
    .where(
        //this will produce the adequate WHERE criterias in addition to your own:
        //(see doc snippet for getting converter and entityInfo)
        N1qlUtils.createWhereFilterForEntity(where, converter, entityInfo));

The part of the documentation in question with the count snippet is in repository.adoc, "Couchbase specifics about changing the base class".

As seen in this stackoverflow question: http://stackoverflow.com/questions/41980587/spring-data-couchbase-custom-repository-method/42009501


Affects: 2.2 GA (Ingalls)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.