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
querydsl mongodb does not generate Q-Classes after upgrade to Spring boot 3 #3651
Comments
I also have this problem, the Q class is not generated. This is very fatal, forcing me to temporarily give up using Querydsl. I hope there is a solution to save this bad situation. environment:springboot 3.2.0 Here are the relevant parts of build.gradle.kts:
Phenomenon:
|
Very good news, I solved this problem and made the following changes based on the build.gradle.kts I posted earlier: 1. Add kapt plug-in
2. Use kapt to build, select jakarta, originally jpa
After recompiling and starting, everything is normal. |
That is nice for jpa, means for postgres users, however on mongoDB this does not help! There is no jakarta classifier.. here the relevant parts of my build.gradle:
|
The Q-Classes for my Postgres entities are getting generated, however not the ones for mongodb entities |
Is it easy to post Mongdb-related entity classes? |
Sure, here one of them: import com.querydsl.core.annotations.QueryEntity;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
@AllArgsConstructor
@Getter
@NoArgsConstructor
@QueryEntity
public class Provider {
private ProviderType type;
/**
* id of the original activity assigned by the provider
*/
private String externalId;
} And here the generated one from the version as we used spring 2.7: import static com.querydsl.core.types.PathMetadataFactory.*;
import com.querydsl.core.types.dsl.*;
import com.querydsl.core.types.PathMetadata;
import javax.annotation.processing.Generated;
import com.querydsl.core.types.Path;
/**
* QProvider is a Querydsl query type for Provider
*/
@Generated("com.querydsl.codegen.DefaultEntitySerializer")
public class QProvider extends EntityPathBase<Provider> {
private static final long serialVersionUID = -2130270020L;
public static final QProvider provider = new QProvider("provider");
public final StringPath externalId = createString("externalId");
public final EnumPath<ProviderType> type = createEnum("type", ProviderType.class);
public QProvider(String variable) {
super(Provider.class, forVariable(variable));
}
public QProvider(Path<? extends Provider> path) {
super(path.getType(), path.getMetadata());
}
public QProvider(PathMetadata metadata) {
super(Provider.class, metadata);
}
} |
Think I've found the problem, have to add the |
Very correct, I was just about to say this. I have always used javax.persistence.@entity. Of course, now in openjdk 21, I use jakarta.persistence.@entity. |
Sorry, but I have to reopen this issue. Since the @jakarta.persistence.Entity annotation makes a lot of trouble with mongodb. Before that, an @jakarta.persistence.Id Annotation was not neccessary, now it is, however we have usecases where no ID is needed and where it makes trouble in some points. i.e. we have a Class A (@entity) which can contain some more complex classes i.e. Lists of Datapoints (also @entity) or complex Datatypes consisting of multiple interger fields. In MongoDB this complex data should be formed to a JSON document i.e.: {
name: classA,
id: 1234,
cadenceData: {
min: 1
mean: 2
max: 3
},
datapoints: [
{ date: XXX, value: 1.2 },
{ date: XXX, value: 1.3 }
...
]
} Now you may see, it is not necessary to have an ID for the cadenceData or for each datapoint, since those are not separated tables as it would be in a SQL based DB. So still wondering how to use queryDSL with gradle and Spring boot 3.0. |
reopen |
As you said, I think it's a relational and non-relational design conflict, and I think the easiest solution right now is to make a compromise between DSL and Mongodb, for example, using @jakarta.persistence.Id to fit the needs of dsl, but actually ignores the existence of this field. |
Thats what I've already tried, however it seems that on this road cascading problems are coming up.. because the next problem after that are JDBC type errors on subclasses used in an Entity. May on of the Maintainers could give a short hint what to do here? |
Having the same problem. I am unable to upgrade my project because of this. |
I also have this issue. There's more problems with Luckily, I was able to find a work-around that works with Spring Boot 3.x. The only drawback here is that the mysema plugin is from 2014 :(, but better then nothing lol.
|
Observed vs. expected behavior
Previously on Spring boot 2.7.17 everything worked fine and the classes were generated as expected. However now I try to upgrade the project to Spring Boot 3 and Spring Cloud 2022.0.3 and querydsl is not working anymore.
The issue is only related to mongodb.
Steps to reproduce
Try generating Q-Classes in the environment describe below
Environment
Spring Boot 3.0.13
Spring Cloud 2022.0.3
Java 17.0.7
Gradle 8.5 (gradle wrapper)
Querydsl version: 5.0.0
Querydsl module: querydsl-mongodb
Database: mongodb
JDK: 17
Additional details
We are using Lombok and jakarta annotation API additionally in the annotation processors
And we are using GraphQL Codegen as well.
The text was updated successfully, but these errors were encountered: