Files
spring-data-examples/mongodb/querydsl
Christoph Strobl a4c5214b39 Update MongoDB samples.
Use default MongoDB container in tests and remove sample for deprecated server side scripting.
2024-11-22 08:55:24 +01:00
..
2024-11-22 08:55:24 +01:00
2022-05-19 11:23:00 -05:00
2019-08-13 12:10:47 +02:00

Spring Data MongoDB - Querydsl example

This project contains samples of Querydsl usage in Spring Data MongoDB.

Querydsl is a framework which enables the construction of fluent, type-safe queries for multiple backends including MongoDB. Spring Data integrates with Querydsl via QuerydslPredicateExecutor and its reactive counterpart ReactiveQuerydslPredicateExecutor.

NOTE: You may have to run mvn compile to generate the required Q classes first.

Imperative

interface CustomerQuerydslRepository 
        extends CrudRepository<Customer, String>, QuerydslPredicateExecutor<Customer> { }

@Autowired CustomerQuerydslRepository repository;

// ...

List<Customer> result = repository.findAll(QCustomer.customer.lastname.eq("Matthews"));

Reactive

interface ReactiveCustomerQuerydslRepository
		extends ReactiveCrudRepository<Customer, String>, ReactiveQuerydslPredicateExecutor<Customer> { }
		
@Autowired ReactiveCustomerQuerydslRepository repository;

// ...

Flux<Customer> result = repository.findAll(QCustomer.customer.lastname.eq("Matthews"));