Scenario ========
Find and return dto (not actual document) from Mongo DB using SpringdataMongo and QueryDsl
scanario
document
Customer{ name, age, city, zip }
JPA repository
interface CustomerQuerydslRepository extends CrudRepository<Customer, String>, QuerydslPredicateExecutor { }
Service Call
{ ... @Autowired CustomerQuerydslRepository repository;
List result = repository.findAll(QCustomer.customer.lastname.eq("Matthews"));
}
since my original document is large, I want to return only few fields and needs that to be mapped to a dto below
dto
CustomerDto{ name, age }
my current workaround is to map returned documents to dto in the service layer but looking for more optimized ways using QueryDSL itself.