1

Hi I have an endpoint like /findBy and it can take several query params similar like ;

findBy?color="blue"&size="big"&city="ny"&country="usa"

How can I have such query in repository layer using spring-data-couchbase. Normally if it would something like findByCity or findByColor only I would have such methods in my repository

@Repository
public interface HouseRepository  extends CouchbaseRepository<House, String> {

    House findByColor(String Color);
    House findByCity(String City);
}

but in this case I might not get all the parameter values. I want to query whatever values I have. Same findBy should return the values in these cases:

findBy?country="usa"
findBy?city="ny"&country="usa"
findBy?color="blue"&size="big"

Can such thing be done using spring data couchbase without writing custom sql queries?

Matthew Groves
  • 25,181
  • 9
  • 71
  • 121
erondem
  • 482
  • 1
  • 11
  • 24

1 Answers1

2
You can use Querydsl Extension.

Querydsl is a framework that enables the construction of statically typed SQL-like queries through its fluent API.

You have QueryDSL integration, you can derive queries from the attributes contained in a Request query string.

Please see these links for more information:

İsmail Y.
  • 3,579
  • 5
  • 21
  • 29