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 a 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
QueryModelType.autodetect() in querydsl-ksp-codegen only recognizes jakarta.persistence.MappedSuperclass for SUPERCLASS models (and jakarta.persistence.Embeddable for EMBEDDABLE). When a @QueryEntity class has a superclass annotated with querydsl's own @QuerySupertype, autodetect returns null and the processor throws:
e: [ksp] java.lang.IllegalStateException: Unable to resolve type of entity for <superclass fqn>
No Q classes are generated. The failure is the same whether the @QuerySupertype base class is source in the same module or comes from a compiled library dependency.
To Reproduce
Generating Q classes for non-JPA (Spring Data R2DBC) entities using querydsl's own annotations:
import com.querydsl.core.annotations.QueryEntity
import com.querydsl.core.annotations.QuerySupertype
import java.time.LocalDateTime
import java.util.UUID
@QuerySupertype
abstract class AuditableEntity(
open var id: UUID? = null,
open var createdDate: LocalDateTime? = null,
)
@QueryEntity
class GroupEntity(
id: UUID? = null,
val name: String,
) : AuditableEntity(id)
dependencies {
implementation("io.github.openfeign.querydsl:querydsl-core:7.4.0")
ksp("io.github.openfeign.querydsl:querydsl-ksp-codegen:7.4.0")
}
Versions: querydsl-ksp-codegen:7.4.0 (affects the @QueryEntity support introduced in 7.1 via #1345), Kotlin 2.1.0, KSP 2.1.0-1.0.29 (KSP2), Gradle 8.10.2, JDK 21.
Expected behavior
KSP codegen should recognize @QuerySupertype and @QueryEmbeddable the same way the classic APT processor does, generate Q supertype classes for @QuerySupertype bases, and generate @QueryEntity subclasses with _super referencing the supertype Q class.
Root cause
QueryModelExtractor.addNew() walks the entity's superclass and calls the single-arg addClass(), which resolves the model type via QueryModelType.autodetect(). QueryModelType.SUPERCLASS.associatedAnnotations only contains jakarta.persistence.MappedSuperclass — querydsl's own com.querydsl.core.annotations.QuerySupertype was never added when @QueryEntity support landed (#1345), so autodetect returns null and addClass throws. EMBEDDABLE has the same gap for com.querydsl.core.annotations.QueryEmbeddable.
Proposed fix
In QueryModelType.kt, add the querydsl-native annotations to the associated annotation lists:
EMBEDDABLE(
listOf(
Embeddable::class.qualifiedName!!,
"com.querydsl.core.annotations.QueryEmbeddable"
)
),
SUPERCLASS(
listOf(
MappedSuperclass::class.qualifiedName!!,
"com.querydsl.core.annotations.QuerySupertype"
)
),
Additional context
I have validated this two-line change locally against 7.4.0 sources on a real two-build project (library @QuerySupertype base + consumer @QueryEntity entities): generation succeeds and the full integration-test suite passes.
A follow-up PR with the fix and regression tests is coming shortly.
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 a 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
QueryModelType.autodetect()inquerydsl-ksp-codegenonly recognizesjakarta.persistence.MappedSuperclassfor SUPERCLASS models (andjakarta.persistence.Embeddablefor EMBEDDABLE). When a@QueryEntityclass has a superclass annotated with querydsl's own@QuerySupertype,autodetectreturns null and the processor throws:No Q classes are generated. The failure is the same whether the
@QuerySupertypebase class is source in the same module or comes from a compiled library dependency.To Reproduce
Generating Q classes for non-JPA (Spring Data R2DBC) entities using querydsl's own annotations:
dependencies { implementation("io.github.openfeign.querydsl:querydsl-core:7.4.0") ksp("io.github.openfeign.querydsl:querydsl-ksp-codegen:7.4.0") }Versions:
querydsl-ksp-codegen:7.4.0(affects the@QueryEntitysupport introduced in 7.1 via #1345), Kotlin 2.1.0, KSP2.1.0-1.0.29(KSP2), Gradle 8.10.2, JDK 21.Expected behavior
KSP codegen should recognize
@QuerySupertypeand@QueryEmbeddablethe same way the classic APT processor does, generate Q supertype classes for@QuerySupertypebases, and generate@QueryEntitysubclasses with_superreferencing the supertype Q class.Root cause
QueryModelExtractor.addNew()walks the entity's superclass and calls the single-argaddClass(), which resolves the model type viaQueryModelType.autodetect().QueryModelType.SUPERCLASS.associatedAnnotationsonly containsjakarta.persistence.MappedSuperclass— querydsl's owncom.querydsl.core.annotations.QuerySupertypewas never added when@QueryEntitysupport landed (#1345), soautodetectreturns null andaddClassthrows.EMBEDDABLEhas the same gap forcom.querydsl.core.annotations.QueryEmbeddable.Proposed fix
In
QueryModelType.kt, add the querydsl-native annotations to the associated annotation lists:Additional context
I have validated this two-line change locally against 7.4.0 sources on a real two-build project (library
@QuerySupertypebase + consumer@QueryEntityentities): generation succeeds and the full integration-test suite passes.A follow-up PR with the fix and regression tests is coming shortly.