Hello, I've been working on getting Spring Data MongoDB to work with QueryDSL for a while.
I just wanted to share my findings and see if it makes sense to update the documentation page.
-
There is no jakarta classifier for querydsl-mongodb (at least not in any of the versions found here), so trying to fetch the dependency with the jakarta classifier fails. And this makes sense because the jakarta classifier makes sense mostly in the context of JPA related libraries.
|
implementation 'com.querydsl:querydsl-mongodb:${querydslVersion}:jakarta' |
-
Generating Q classes
QueryDSL does not support any Spring data annotations like @Document so by default Q-class is not generated. I think this part of the document is trying to solve this issue
|
tasks.withType(JavaCompile).configureEach { |
|
options.compilerArgs += [ |
|
"-processor", |
|
"org.springframework.data.mongodb.repository.support.MongoAnnotationProcessor"] |
|
} |
but unfortunately if the project uses other QueryDSL annotation processors, those processors also have to be manually added to this list as well (I may be wrong. This is my speculation. Apologies, I am new to Java build systems). For example, for my project, I was using QueryDSL JPA as well, and when I added the above lines to my build.gradle Q-classes for my JPA entities were not generated.
I ended up using com.querydsl.core.annotations.QueryEntity annotation on my document entity class that is processed by the annotation processor provided by querydsl-apt with general classifier (ex. 'com.querydsl:querydsl-apt:5.0.0:general').
After that I was able to use methods from QuerydslPredicateExecutor with the generated Q-class.
Frankly, I am not sure what would be a clear solution for number 2. Since my case is a bit specific and the solution is a workaround to the actual issue which is being able generate Q-class with Spring Data MonogDB annotations.
But at least I wanted to point out number 1 and share the findings I had for number 2 to see if the documentation can be improved.
Hello, I've been working on getting Spring Data MongoDB to work with QueryDSL for a while.
I just wanted to share my findings and see if it makes sense to update the documentation page.
There is no
jakartaclassifier forquerydsl-mongodb(at least not in any of the versions found here), so trying to fetch the dependency with thejakartaclassifier fails. And this makes sense because thejakartaclassifier makes sense mostly in the context of JPA related libraries.spring-data-mongodb/src/main/antora/modules/ROOT/pages/repositories/core-extensions.adoc
Line 219 in f5359d5
Generating Q classes
QueryDSL does not support any Spring data annotations like
@Documentso by default Q-class is not generated. I think this part of the document is trying to solve this issuespring-data-mongodb/src/main/antora/modules/ROOT/pages/repositories/core-extensions.adoc
Lines 228 to 232 in f5359d5
but unfortunately if the project uses other QueryDSL annotation processors, those processors also have to be manually added to this list as well (I may be wrong. This is my speculation. Apologies, I am new to Java build systems). For example, for my project, I was using QueryDSL JPA as well, and when I added the above lines to my
build.gradleQ-classes for my JPA entities were not generated.I ended up using
com.querydsl.core.annotations.QueryEntityannotation on my document entity class that is processed by the annotation processor provided byquerydsl-aptwithgeneralclassifier (ex.'com.querydsl:querydsl-apt:5.0.0:general').After that I was able to use methods from
QuerydslPredicateExecutorwith the generated Q-class.Frankly, I am not sure what would be a clear solution for number 2. Since my case is a bit specific and the solution is a workaround to the actual issue which is being able generate Q-class with Spring Data MonogDB annotations.
But at least I wanted to point out number 1 and share the findings I had for number 2 to see if the documentation can be improved.