Does Spring Data `2021.0.1` support Kotlin `1.5`? ...
# spring
m
Does Spring Data
2021.0.1
support Kotlin
1.5
? The docs at https://docs.spring.io/spring-data/mongodb/docs/3.2.1/reference/html/#kotlin.requirements say
Spring Data supports Kotlin 1.3...
I seem to be hitting an issue when reading an immutable
data class
from Mongo due to the presence of the final parameter of the constructor being of type `kotlin.jvm.internal.DefaultConstructorMarker`: I get an exception
org.springframework.data.mapping.MappingException: Parameter org.springframework.data.mapping.PreferredConstructor$Parameter@80a6e44c does not have a name!
. The parameter in question is, indeed, the
DefaultConstructorMarker
. I'm using Spring Data MongoDB
3.2.1
w/commons
2.5.1
.
Offending
data class
is :
Copy code
sealed interface Availability {
    companion object {
        val CONVENTIONAL_8TO5_WITH_LUNCH_RECURRENCE: CronString = "0/30 8-12,13-17 * * MON-FRI"
        val CONVENTIONAL_8TO5_RECURRENCE: CronString = "0/30 8-17 * * MON-FRI"
        val CONVENTIONAL_9TO5_WITH_LUNCH_RECURRENCE: CronString = "0/30 9-12,13-17 * * MON-FRI"
        val CONVENTIONAL_9TO5_RECURRENCE: CronString = "0/30 9-17 * * MON-FRI"

        val DEFAULT_RECURRENCE = CONVENTIONAL_9TO5_WITH_LUNCH_RECURRENCE
        val DEFAULT_SLOT_MINUTES = 30U.toUByte()
        val DEFAULT_ALLOWED_BOOKING_COUNT = 1U.toUByte()
    }

    val handle: String
    val slotMinutes: UByte
    val allowedBookingCount: UByte
    val name: String?
    val effectivity: Interval?
}

data class RecurringAvailability(
    val recurrence: CronString = DEFAULT_RECURRENCE,
    override val handle: String = UUID.randomUUID().toString(),
    override val slotMinutes: UByte = DEFAULT_SLOT_MINUTES,
    override val allowedBookingCount: UByte = DEFAULT_ALLOWED_BOOKING_COUNT,
    override val effectivity: Interval? = null,
    override val name: String? = null,
) : Availability
(fyi,
CronString
is
typealias CronString = String
)
Figured it out. I was using Kotlin unsigned byte types, which leverage inline classes. Bug that I hit was https://github.com/spring-projects/spring-data-commons/issues/1947. Also relevant was https://github.com/spring-projects/spring-data-commons/issues/2215#issuecomment-752410346