Working with Entities in JPA I come across something like this:
@Entity
class Foo {
@OneToMany(mappedBy = "foo")
val bars : MutableList<Bar> by lazy { ArrayList<Bar>() }
}
This is a nice pattern such that when the Entity is new, it’ll create a new empty List for Bars, but the underlying framework will set the list (with field access) for existing Foos.
the problem is that kotlin generates the error:
Kotlin: This annotation is not applicable to target ‘member property without backing field’
Not a big deal, but was wondering if there is a nice way to make this work.