Skip to content

ksp-codegen generates unqualified type reference for @EmbeddedId inner class #1805

Description

@mobpolice
  • I am willing to put in the work and submit a PR to resolve this issue.

Describe the bug
When @EmbeddedId is declared as an inner class of a JPA entity,
ksp-codegen generates an unqualified type reference that fails to compile.

To Reproduce
Add a JPA entity with an @EmbeddedId declared as an inner class:

@Entity
class Invoice(
    @EmbeddedId val id: InvoiceId
) {
    @Embeddable
    data class InvoiceId(
        val invoiceNo: String = "",
        val seq: Int = 0
    ) : Serializable
}

Running kspKotlin generates QInvoice_InvoiceId.kt with an unqualified type reference that fails to compile.

Generated (wrong)

BeanPath<InvoiceId>  // cannot be resolved

Expected

BeanPath<Invoice.InvoiceId>  // correct qualified reference

Root cause

QueryModelExtractor.toQueryModel() builds originalClassName using only classDeclaration.simpleName, which drops the enclosing class from the generated type reference.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions