Marcus Ilgner
08/18/2023, 11:26 AMnull
values in the DB using Arrow's Option<T>
instead of T?
. But I guess that Hibernate probably wouldn't know how to deal with Option
?raulraja
08/18/2023, 2:51 PMOption
in Hibernate you would have to implement a AttributeConverter
or similar interface to tell Hibernate how to serialize and deserialize the value:
Something like this, untested and assuming Hibernate would support polymorphic converters with generic type args:
import javax.persistence.AttributeConverter
import javax.persistence.Converter
@Converter
class OptionConverter<A> : AttributeConverter<Option<A>, A> {
fun convertToDatabaseColumn(optionValue: Option<A>): A? =
optionValue.getOrElse { null }
fun convertToEntityAttribute(dbValue: A?): Option<A> =
Option.fromNullable(dbValue)
}
Marcus Ilgner
08/21/2023, 5:45 AMOliver Eisenbarth
08/22/2023, 3:13 PMjava.util.Optional
• com.google.common.base.Optional
• scala.Option
• io.vavr.control.Option
My gut tells me, that things could work with Kotlin-Vavr, too.
Integration code doesn't seem much, you could do a PR for Arrow's Option<T>. 🤪