You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We log entity classes before saving them to the database
data class MyEntity(
val text: String,
... other required properties
) {
lateinit var createAt: Instant // this field is initialized after the entity is saved to the Database
}
fun save(entity: MyEntity) {
log.info("About to save ${objectMapper.writeValueAsString(entity)}")
repository.save(entity)
}
Describe the solution you'd like
A new feature flag
val module = KotlinModule.Builder()
.configure(KotlinFeature.UnintializedLateInitToNull, true) // to write them as nulls
.configure(KotlinFeature.UnintializedLateInitToIgnore, true) // or to avoid them
.build()
Describe alternatives you've considered
No response
Additional context
No response
The text was updated successfully, but these errors were encountered:
I can think of roughly two ways to make serialization work in this situation.
One is to ignore the getter and use the field for serialization.
The other is to hack the JsonFilter mechanism and display nothing if it is before initialization.
However, the feasibility of both has not been confirmed.
Also, it should be discussed how it should be handled based on consistency with functions such as JsonSetter(nullsUsing = ...).
For now, I feel that the policy of “serialize to undefined if not yet initialized” is the way to go, but I can understand the opinion that it should be serialized as null.
Use case
We log entity classes before saving them to the database
Describe the solution you'd like
A new feature flag
Describe alternatives you've considered
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: