Skip to content

Clarify QueryDSL usage in reference documentation #4951

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
hojoungjang opened this issue Apr 21, 2025 · 2 comments
Closed

Clarify QueryDSL usage in reference documentation #4951

hojoungjang opened this issue Apr 21, 2025 · 2 comments
Assignees
Labels
type: documentation A documentation update

Comments

@hojoungjang
Copy link

hojoungjang commented Apr 21, 2025

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.

  1. 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'

  2. 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.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Apr 21, 2025
@mp911de mp911de added type: documentation A documentation update and removed status: waiting-for-triage An issue we've not yet triaged labels Apr 22, 2025
@mp911de mp911de self-assigned this Apr 22, 2025
@mp911de
Copy link
Member

mp911de commented Apr 22, 2025

Good catch about the jakarta classifier, that's an oversight on our end.

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.

Our documentation shows the simple case, assuming you're not already using annotation processing. I think we can call out that specifying annotation processors by class name requires specifying all annotation processors that way.

@mp911de mp911de changed the title Clarify QueryDSL usage on the documentation page Clarify QueryDSL usage in reference documentation Apr 22, 2025
mp911de added a commit that referenced this issue Apr 22, 2025
mp911de added a commit that referenced this issue Apr 22, 2025
@mp911de mp911de added this to the 4.4.5 (2024.1.5) milestone Apr 22, 2025
@hojoungjang
Copy link
Author

That sounds good. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: documentation A documentation update
Projects
None yet
Development

No branches or pull requests

3 participants