Micronaut Data JDBC + KSP - Unrecognised Embedded ID Query Parameter

54 views Asked by At

I'm migrating a project using micronaut-data-jdbc from Kapt -> KSP. I have an entity with an embedded ID with an 'upsert' method that takes a list of entities to persist. This was working fine with Kapt, but now with KSP it isn't able to resolve the query parameters from the embedded ID.

Reproducer repo: https://github.com/jayblackalto/ksp-bug-report

My code:

@Embeddable
data class TheEmbeddedId(
    val a: UUID,
    val b: String,
    val c: String,
)

data class TheEntity(
    @EmbeddedId val id: TheEmbeddedId,
    val value: Double,
    val updated: Instant,
)

@JdbcRepository(dialect = Dialect.POSTGRES)
abstract class TheEntityRepository : GenericRepository<TheEntity, TheEmbeddedId> {

    @Query(
        """
            INSERT INTO the_entity (id_a, id_b, id_c, value, updated)
                 VALUES (:a, :b, :c, :value, :updated)
            ON CONFLICT ON CONSTRAINT pk_the_entity DO UPDATE
                    SET value = :value, updated = :updated;
        """,
        readOnly = false,
    )
    abstract suspend fun upsert(entity: TheEntity)
}

The output from KSP:

[ksp] /[ksp] /Users/me/work/ksp-bug-report/src/main/kotlin/com/kspdata/TheEntityRepository.kt:38: Unable to implement Repository method: TheEntityRepository.upsert(TheEntity entity). No method parameter found for named Query parameter: a

My question: is there some other way I should be referencing the 'a' property of the embedded ID, or is this a bug in the KSP processor?

0

There are 0 answers