Reimplement data class copy method to consider variables in subclasses.
Idea is to implement something like this
@Entity
data class SomeEntity(val name: String, val age: Int) : EntityBase()
@Copy("entityId")
abstract class EntityBase : OtherBase() {
var id: String? = null
}
abstract class OtherBase {
var someOtherVariable = 123
}val someEntity = SomeEntity("David", 24)
someEntity.id = "100000"
someEntity.someOtherVariable = 100000
val coppiedEntity = someEntity.copy(name = "Milan")
assertEquals(coppiedEntity.name == "Milan") // As data class is expected to work normally
assertEquals(coppiedEntity.age == 24) // As data class is expected to work normally
assertEquals(coppiedEntity.id == "100000") // Because id variable is mentioned in @Copy annotation
assertEquals(coppiedEntity.someOtherVariable == null) // Because someOtherVariable is not mentioned in @Copy annotation, and OtherBase class doesn't have its own @Copy annotation