Skip to content

Autoconfigure and QueryDSL #40965

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
ashutoshopengov opened this issue May 31, 2024 · 4 comments
Closed

Autoconfigure and QueryDSL #40965

ashutoshopengov opened this issue May 31, 2024 · 4 comments
Labels
for: external-project For an external project and not something we can fix status: declined A suggestion or change that we don't feel we should currently apply

Comments

@ashutoshopengov
Copy link

I spent most of my week trying to figure this out. It was genuinely very frustrating.
Spring boot 3 does not support javax.persistence APIs and has migrated to jakarta.persistence.
But for some darned reason we import com.querydsl:querydsl-apt:5.0.0 and com.querydsl:querydsl-jpa:5.0.0 instead of their jakarta support versions -- com.querydsl:querydsl-apt:5.0.0:jakarta, com.querydsl:querydsl-jpa:5.0.0:jakarta

Please update this or tell me where i can go to raise a PR for this in the autoconfigure plugin.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label May 31, 2024
@wilkinsona
Copy link
Member

Spring Boot itself doesn't do anything with querydsl-jpa and it isn't a dependency in Spring Boot's build. Spring Data JPA does depend on querydsl-jpa but it's already using the jakarta classifier:

<dependency>
	<groupId>com.querydsl</groupId>
	<artifactId>querydsl-jpa</artifactId>
	<classifier>jakarta</classifier>
	<version>${querydsl}</version>
	<optional>true</optional>
</dependency>

Can you please describe the problem that you faced in some more detail? Right now, I don't think we have enough information to identify what should be changed or where that change needs to happen.

@wilkinsona wilkinsona added the status: waiting-for-feedback We need additional information before we can continue label May 31, 2024
@ashutoshopengov
Copy link
Author

ashutoshopengov commented May 31, 2024

Wow that was a quick reply.

I was trying to import querydsl directly in my gradle project.
We use spring boot autoconfigure in our project (so that we dont have to manage versions, wonders of spring boot yeah).
The following import does not get you the jakarta version of the dependencies.

    implementation("com.querydsl:querydsl-core")
    implementation("com.querydsl:querydsl-jpa")
    annotationProcessor("com.querydsl:querydsl-apt")

Additionally, I was also referring to this dependency versions doc which doesnt mention the jakarta release of the thing. Might be a miss?
https://docs.spring.io/spring-boot/docs/3.2.4/reference/html/dependency-versions.html#appendix.dependency-versions.properties

There was also a bug from someone who ended up hinting me at what was wrong https://stackoverflow.com/questions/74756871/spring-boot-3-with-querydsl

Anyway, my issue is solved but i would like to just add this in somewhere so that someone else doesn't face the same struggles

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels May 31, 2024
@wilkinsona
Copy link
Member

We use spring boot autoconfigure in our project (so that we dont have to manage versions, wonders of spring boot yeah).

It's not Spring Boot's auto-configuration that allows you to omit the versions, it's Spring Boot's dependency management. In the case of your sample project, it's being applied through dependency management plugin but you'd see the same behaviour if you used Gradle's platform support.

implementation("com.querydsl:querydsl-jpa")

It's to be expected that this does not get you the Jakarta version as you have told Gradle that you want the standard non-classified variant. You'd see the same behaviour with Maven if you declared the dependency without a classifier.

Whether you're using the dependency management plugin or Gradle's platform support, you need to specify the classifier when declaring the dependency. The answers on Stack Overflow touch on this, but they're all more verbose than needed. You can use this syntax to declare a classifier while allowing the version to be controlled separately:

implementation("com.querydsl:querydsl-jpa::jakarta")

Note the :: which omits the version, allowing it to be provided by either the dependency management plugin or a platform dependency. This capability is described in Gradle's documentation where it notes that "all properties, except name, are optional".

I was also referring to this dependency versions doc which doesnt mention the jakarta release of the thing

We wanted to include the classifier information in the documentation but, unfortunately, it wasn't possible to do so in a way that would be scalable and maintainable for the number of dependencies that Boot manages.

Given that Spring Boot itself doesn't do anything with querydsl-jpa, there isn't really a natural place in the documentation to mention the need for the classifier. I think it would be better to document it in Spring Data JPA's documentation where there's an existing section on QueryDSL. If you would like to see that happen, please open a Spring Data JPA issue.

@wilkinsona wilkinsona closed this as not planned Won't fix, can't repro, duplicate, stale May 31, 2024
@wilkinsona wilkinsona added status: declined A suggestion or change that we don't feel we should currently apply for: external-project For an external project and not something we can fix and removed status: waiting-for-triage An issue we've not yet triaged status: feedback-provided Feedback has been provided labels May 31, 2024
@jamesdh
Copy link

jamesdh commented Aug 11, 2024

Spring Boot itself doesn't do anything with querydsl-jpa and it isn't a dependency in Spring Boot's build.

This isn't completely accurate. It does define the querydsl-bom, which in turn defines querydsl-jpa without the jakarta classifier. This was last updated to 5.1 here as part of the Spring Boot 3.3.0 release.

This is actually causing us some very confusing pain. We were already manually defining 5.1.0:jakarta since we upgraded Spring Boot from 2.7.11 to 3.0.6, and it worked great. But now that I'm trying to upgrade Spring Boot from 3.2.x to 3.3.x, I'm unable to get QueryDSL's JPAAnnotationProcessor to work. The versions + classifiers of the dependencies are all the same as before. Will try and create + commit a small reproducible app to demonstrate and open an issue for it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
for: external-project For an external project and not something we can fix status: declined A suggestion or change that we don't feel we should currently apply
Projects
None yet
Development

No branches or pull requests

4 participants