Код: Выделить всё
@Entity(foreignKeys = [
ForeignKey(
entity = CategoryEntity::class,
childColumns = ["categoryId"],
parentColumns = ["id"]
)
])
data class ItemEntity (
@PrimaryKey val id: String,
val title: String = "",
val description: String?,
val priority: Int = 0,
val createAt: Long = 0L,
val categoryId: String = ""
)
Код: Выделить всё
@Entity(tableName = "category_entity")
data class CategoryEntity (
@PrimaryKey val id: String,
val name: String = ""
)
Код: Выделить всё
data class ItemAndCategoryEntity (
@Embedded val itemEntity: ItemEntity,
@Relation(
parentColumn = "categoryId",
entityColumn = "id"
)
val categoryEntity: CategoryEntity
)


Файл на изображении ( ItemEntityDAO_impl) генерируется автоматически, и для меня это странно, почему созданный класс, которого не существует?
Вот мой файл DAO:
Код: Выделить всё
@Dao
interface ItemEntityDAO {
@Query("SELECT * FROM ItemEntity")
fun getAll(): Flow
@Transaction
@Query("SELECT * FROM ItemEntity")
fun getItemCategory(): Flow
@Insert(onConflict = OnConflictStrategy.REPLACE)
suspend fun insert(itemEntity: ItemEntity)
@Delete
suspend fun delete(itemEntity: ItemEntity)
@Update
suspend fun update(itemEntity: ItemEntity)
}
Код: Выделить всё
//Kotlin Room database
def room_version = "2.5.1"
kapt "androidx.room:room-compiler:$room_version"
implementation "androidx.room:room-ktx:$room_version"
Подробнее здесь: https://stackoverflow.com/questions/761 ... lationutil
Мобильная версия