You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/main/antora/modules/ROOT/pages/mongodb/repositories/repositories.adoc
+104-8
Original file line number
Diff line number
Diff line change
@@ -213,7 +213,7 @@ Inside the test method, we use the repository to query the datastore.
213
213
We hand the repository a `PageRequest` instance that requests the first page of `Person` objects at a page size of 10.
214
214
215
215
[[mongodb.repositories.queries.type-safe]]
216
-
== Type-safe Query Methods
216
+
== Type-safe Query Methods with Querydsl
217
217
218
218
MongoDB repository and its reactive counterpart integrates with the http://www.querydsl.com/[Querydsl] project, which provides a way to perform type-safe queries.
NOTE: Please note that joins (DBRef's) are not supported with Reactive MongoDB support.
340
346
====
341
347
======
348
+
349
+
[[mongodb.repositories.queries.type-safe.apt]]
350
+
=== Setting up Annotation Processing
351
+
352
+
To use Querydsl with Spring Data MongoDB, you need to set up annotation processing in your build system that generates the `Q` classes.
353
+
While you could write the `Q` classes by hand, it is recommended to use the Querydsl annotation processor to generate them for you to keep your `Q` classes in sync with your domain model.
354
+
355
+
Spring Data MongoDB ships with an annotation processor javadoc:org.springframework.data.mongodb.repository.support.MongoAnnotationProcessor[] that isn't registered by default.
356
+
Typically, annotation processors are registered through Java's service loader via `META-INF/services/javax.annotation.processing.Processor` that also activates these once you have them on the class path.
357
+
Most Spring Data users do not use Querydsl, so it does not make sense to require additional mandatory dependencies for projects that would not benefit from Querydsl.
358
+
Hence, you need to activate annotation processing in your build system.
359
+
360
+
The following example shows how to set up annotation processing by mentioning dependencies and compiler config changes in Maven and Gradle:
0 commit comments