I have a list of items like the below that I would like to enter into a database using room.
data class MyRotasDayItem(
@PrimaryKey
@SerializedName("id")
val id: Long,
@SerializedName("date")
val date: String,
@Embedded
@SerializedName("dayEvents")
val dayEvents: List<SealedObj>
)
However I cant seem to add dayEvents. Even if I made the type List I get... Entities and POJOs must have a usable public constructor Do i have to use a type converter?
What if in the list Type is a Sealed class that contain other data objects like...
sealed class MySealedExample(
open val foo: Long,
open val bar: Long
) {
@PrimaryKey(autoGenerate = true)
var id: Int = 0
@Entity
data class AnExample1(
@Ignore override val foo: Long,
@Ignore override val bar: Long,
val something:String
) : MySealedExample(foo, bar)
@Entity
data class AnExample2(
@Ignore override val foo: Long,
@Ignore override val bar: Long,
val somethingElse:List<SomeObj>
) : MySealedExample(foo, bar)
}
Anyway to insert that into the database?
Thankyou