I have 3 entities:
product_table
@Entity(tableName = "products_table")
data class Product (
@PrimaryKey(autoGenerate = true) val id: Int,
val name: String,
val price: Double
)
planned_lists_table
@Entity(tableName = "planned_lists_table")
data class PlannedList (
@PrimaryKey(autoGenerate = true) val id: Int,
val name: String,
val budget: Double
)
and selected_products_table
@Entity(tableName = "selected_products_table",
foreignKeys = [
ForeignKey(
entity = PlannedList::class,
parentColumns = ["id"],
onDelete = ForeignKey.CASCADE,
childColumns = ["productListId"])
])
data class SelectedProduct (
@PrimaryKey(autoGenerate = true) val id: Int,
val productListId: Int,
@Embedded(prefix = "ref_") val product: Product,
val amount: Int,
val checked: Boolean // checked if a user has gotten a product
)
I'm trying to figure out how to fetch data from both tables - product_table and selected_products_table. I've chosen @Embedded annotation, but now when I compile the project, Room says next:
Entities and POJOs must have a usable public constructor. You can have an empty constructor or a constructor whose parameters match the fields (by name and type). - kotlin.Unit
I'm aware that I can't use embedded classes that contain something like List and my tables seem not to have any.
What do I need to do to fix the problem?