Is there any chance to make the @Id
property non-nullable for Mongo-related entities in Kotlin?
Referring to this post there seems to be a solution for SQL by setting the ID initially to 0
. However, that seems like a hack, and seems to work only when using sequence generators.
My original intent is obviously to avoid nullable IDs like I have right now:
@Document class MyEntity( @Id var id: String? = null )
What I'd prefer if possible:
@Document class MyEntity( @Id val id: String )