Find file
Fetching contributors…
Cannot retrieve contributors at this time
77 lines (60 sloc) 2.14 KB

Querydsl Mongodb

The Mongodb module provides integration with the Mongodb API.

Maven integration

Add the following dependencies to your Maven project :



And now, configure the Maven APT plugin which generates the query types used by Querydsl :


The MorphiaAnnotationProcessor finds domain types annotated with the annotation and generates Querydsl query types for them.

Run mvn clean install and you will get your Query types generated into target/generated-sources/java.

If you use Eclipse, run mvn eclipse:eclipse to update your Eclipse project to include target/generated-sources/java as a source folder.

Now you are able to construct Mongodb queries and instances of the query domain model.

Example query

Querying with Querydsl Mongodb with Morphia is as simple as this :

Morphia morphia;
Datastore datastore;
// ...  
QUser user = new QUser("user");
MorphiaQuery<User> query = new MorphiaQuery<User>(morphia, datastore, user);
List<User> list = query

For more information on the Querydsl Mongodb module visit the reference documentation