Skip to content

Kotlin lazy property identified as persistent entity #3112

Closed
@maio

Description

@maio

Hello,

first thanks for a great library!

I encountered following problem. I have a Money data class in Kotlin and when I try to use it in my
DB entity as an @Embedded as follows:

data class Money(val value: BigDecimal, val currency: String) {
    val foo by lazy { 123 }
}

interface CardsRepositoryV1 : CrudRepository<CardsRepositoryV1.CardRow, Long> {
    @Table(value = "cards_v1")
    data class CardRow(
        ...,
        @Embedded(prefix = "effective_amount_", onEmpty = Embedded.OnEmpty.USE_NULL)
        val effectiveAmount: Money
    )
}

repository.deleteAll()

Then I get this error:

org.springframework.data.relational.core.conversion.DbActionExecutionException: Failed to execute DbAction.DeleteAll(propertyPath=effectiveAmount.foo$delegate)
Caused by: org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "LAZY" not found; SQL statement:
DELETE FROM "LAZY" WHERE "LAZY"."CARDS_V1" IS NOT NULL [42102-224]

Am I doing something wrong?

PS: I'm using Spring Boot 3.2.5

Thanks,
Marian

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions