micronaut-projects / micronaut-projects/micronaut-data

Kotlin immutable classes cannod be modified in v3

Open
#4,041 1 comment 1 reaction 1 assignee Claimed by @graemerocher View on GitHub
info: workaround available lang: kotlin status: awaiting validation type: bug
Dominant language
Java
Stars
482
Forks
229
Avg merge
1d 7h
Merged PRs (30d)
32

Description

Looks like something is changed and for the cases like this when Kotlin generates multiple constructors, the empty one is being picked up in v3, preventing modifying the bean with `withValue` method.
```
@MappedEntity
data class SomeEntity(
@field:GeneratedValue
@field:Id
val id: Long? = null,
val something: Int? = null
)
```
The workaround is to remove the defaults:
```
@MappedEntity
data class SomeEntity(
@field:GeneratedValue
@field:Id
val id: Long?
val something: Int?
)
```

I think we should change how we select the bean constructor, we should prefer the constructor that is able to initialize the maximum about of the immutable properties.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.