Azure / Azure/azure-sdk-for-java

[FEATURE REQ] Implement query by example in spring-data-cosmos

Open
#45,919 5 comments 0 reactions 2 assignees Assigned to @kushagraThapar View on GitHub
azure-spring-cosmos customer-reported feature-request needs-team-attention
Dominant language
Java
Stars
2.6k
Forks
2.2k
Avg merge
2d 8h
Merged PRs (30d)
178

Description

**Is your feature request related to a problem? Please describe.**
[Query by example](https://docs.spring.io/spring-data/jpa/reference/repositories/query-by-example.html) API drastically reduces the code needed to implement dynamic searches in spring data.

**Describe the solution you'd like**
SimpleCosmosRepository and SimpleReactiveCosmosRepository should implement the QueryByExampleExecutor and the ReactiveQueryByExampleExecutor interfaces respectively. And the implementations should follow [SimpleJpaRepository](https://github.com/spring-projects/spring-data-jpa/blob/main/spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/support/SimpleJpaRepository.java) and [SimpleMongoRepository](https://github.com/spring-projects/spring-data-mongodb/blob/main/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/support/SimpleMongoRepository.java) implementations from spring-data-jpa and spring-data-mongo as references

**Describe alternatives you've considered**
Currently the only way to implement search queries in spring-data-cosmos is to implement named queries or custom queries in the spring repositories which requires to consider when writing the code to establish all the possible parameters combinations and the adding to the code ways to handle the possible null values of the query.
This is directly addressed by the query by example API.

**Additional context**
I have created a [draft PR](https://github.com/Azure/azure-sdk-for-java/pull/45918) with a possible solution for this which I am still fully testing but would much appreciate any feedback about it.

**Information Checklist**
Kindly make sure that you have added all the following information above and checkoff the required fields otherwise we will treat the issuer as an incomplete report
- [x] Description Added
- [x] Expected solution specified

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.