-
-
Notifications
You must be signed in to change notification settings - Fork 53
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
Kotlin codegen generates invalid code when a parameterized mapped superclass is used #891
Comments
Please note that I also tested the same scenario using the KSP codegen, but it results in a different error. Unfortunately I am not able to properly diagnose that issue, as KSP is not something I know how to work with:
Do let me know if you'd like a separate issue filed for the KSP codegen issue, but please take note that I won't be able to assist in that case. |
Looking at the ExampleBaseEntity class you provided. I tried to add a fallback where it will just use SimplePath for any types not yet covered. class QExampleBaseEntity : EntityPathBase<ExampleBaseEntity<*>> {
public val id: SimplePath<Serializable> = createSimple("id", java.io.Serializable::class.java)
// constructors ...
companion object {
@JvmField
val exampleBaseEntity: QExampleBaseEntity =
com.querydsl.example.ksp.QExampleBaseEntity("exampleBaseEntity")
}
} If this works for you then i can make a pull request for it. |
Switching to the java codegen I get this generated Q-class for the example I provided above: /**
* QExampleBaseEntity is a Querydsl query type for ExampleBaseEntity
*/
@SuppressWarnings("this-escape")
@Generated("com.querydsl.codegen.DefaultSupertypeSerializer")
public class QExampleBaseEntity extends EntityPathBase<ExampleBaseEntity<? extends java.io.Serializable>> {
private static final long serialVersionUID = 668380935L;
public static final QExampleBaseEntity exampleBaseEntity = new QExampleBaseEntity("exampleBaseEntity");
public final SimplePath<java.io.Serializable> id = createSimple("id", java.io.Serializable.class);
@SuppressWarnings({"all", "rawtypes", "unchecked"})
public QExampleBaseEntity(String variable) {
super((Class) ExampleBaseEntity.class, forVariable(variable));
}
@SuppressWarnings({"all", "rawtypes", "unchecked"})
public QExampleBaseEntity(Path<? extends ExampleBaseEntity> path) {
super((Class) path.getType(), path.getMetadata());
}
@SuppressWarnings({"all", "rawtypes", "unchecked"})
public QExampleBaseEntity(PathMetadata metadata) {
super((Class) ExampleBaseEntity.class, metadata);
}
} So I guess it does use SimplePath: I couldn't help but notice that KSP uses a star type parameter I myself would prefer to use the KSP plugin, but our project is using Maven as a build tool, which leaves us without options to run KSP plugins 😢 |
That helps, thank you. |
Hi @IceBlizz6 |
This issue has been automatically marked as stale due to inactivity. If no further action is taken, it will be closed in 7 days. |
This issue has been automatically closed due to prolonged inactivity. |
Important Notice
Thank you for opening an issue! Please note that, as outlined in the README, I currently only work on feature requests or bug fixes when sponsored. Balancing this project with professional and personal priorities means I have a very limited amount of effort I can divert to this project.
You must put in the work to address this issue, or it won't be addressed.
Describe the bug
When using a parameterized mapped superclass the generated Q-classes are invalid with respect to the generic parameters.
To Reproduce
A test example can be seen at https://github.com/jpmsilva/openfeign-querydsl/tree/kotlin-codegen-generic-supertype (branched from the 6.10.1 release).
Running
clean package -P quickbuild
from the folder querydsl-examples/querydsl-example-kotlin-codegen shows the issue:Expected behavior
Build should complete without errors.
Screenshots
N/A
Desktop (please complete the following information):
N/A
Smartphone (please complete the following information):
N/A
Additional context
I might be able to submit a PR to properly set the
out
keyword in the superclass parameters of the generated Q-classes. This aligns the generated Kotlin Q-classes with the Java Q-classes with regards to entity parameters, when they are used.When using the Java codegen variant these generic mapped superclass types are properly handled. The issue only happens in the Kotlin codegen module.
The text was updated successfully, but these errors were encountered: