How can I have a default value for an associated e...
# komapper
z
How can I have a default value for an associated entity? I have this Guild entity, that I want it to have a default config
Copy code
@KomapperEntity
@KomapperAggregateRoot("guilds")
@KomapperOneToOne(targetEntity = MarkovConfig::class)
@KomapperOneToMany(targetEntity = Filter::class, navigator = "filters")
@KomapperOneToMany(targetEntity = DBMessage::class, navigator = "messages")
data class Guild(
    @KomapperId
    @KomapperColumn("GUILD_ID")
    val id: Snowflake
)

@KomapperEntity
@KomapperOneToOne(targetEntity = Guild::class)
data class MarkovConfig(
    @KomapperId
    val id: Int = 0,
    val guildId: Snowflake,
    val enabled: Boolean = true,
    val frequency: Float = 0.5f,
    val handleMention: Boolean = true
)
t
If a database column has a value of NULL, do you want to set a default value for the property corresponding to that column? Unfortunately that is not supported.
z
Well every guild should have a Markov config instance, it should never be null ideally