Data Hierarchy is :
- Place
- id
- name
- images
- original_image
- id
- image_url
- width
- height
- thumbnail_image
- id
- image_url
- width
- height
- original_image
The original_image equals with thumbnail_image.
My Place class is
@Entity
class PlaceEntity(.....) {
@PrimaryKey
var id: Int = id
var name: String = name
@Embedded
var images: Images = images
}
My Images class is
class Images(.....) {
@Relation(parentColumn = "origin_id", entityColumn = "id")
var original: Image = original
@Relation(parentColumn = "thumb_id", entityColumn = "id")
var thumbnail: Image = thumbnail
}
My Image class is
class Image(.....) {
var id: Int = id
var url: String = url
var width: Int = width
var height: Int = height
}
When I compiled this project, room library returns error
error: Cannot find the parent entity column
origin_id
in com.test.room.entity.Images. Options: private com.test.room.entity.Image original;
error: Cannot find the parent entity column
thumb_id
in com.test.room.entity.Images. Options: private com.test.room.entity.Image thumbnail;
error: 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). public final class Images {