I have a Spring MVC/Spring Data / Mongo DB application. I have setted up my environement according the the spring data documentation and my repositories work fine (I can execute queries with predicates)
I was wondering if it was possible to execute a type safe query (using Spring Data and QueryDSL) while making a projection (I want only a few fields of a very big document).
The QueryDSL documentation gives an example for Hibernate but states it can be done in all modules QueryDSL Documentation (but I haven't been able to find out how to do it with Mongo)
here's the code snippet for hibernate
class CustomerDTO {
@QueryProjection
public CustomerDTO(long id, String name){
...
}
QCustomer customer = QCustomer.customer;
JPQLQuery query = new HibernateQuery(session);
List<CustomerDTO> dtos = qry.from(customer).list(new QCustomerDTO(customer.id, customer.name));
Any Ideas ?
This is currently not supported. Feel free to add a ticket for it into our Issue tracker.
The Lucene and Mongodb modules of Querydsl support only direct projections from the query root, but for custom projections something could be figured out.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With