Reputation: 93
I want to implement Android Room persistence. This is my DAO interface.
@Dao
interface FoodDao {
/**
* Returns all data in table for Paging
*
* @param query a dynamic SQL query
*/
@RawQuery
fun getAll(query: SupportSQLiteQuery): DataSource.Factory<Int, Food>
}
For some reason, I have this compile error:
error: Observable query return type (LiveData, Flowable, DataSource, DataSourceFactory etc) can only be used with SELECT queries that directly or indirectly (via @Relation, for example) access at least one table. For @RawQuery, you should specify the list of tables to be observed via the observedEntities field. public abstract androidx.paging.DataSource.Factory<java.lang.Integer, com.google.developers.teacup.data.Tea> getAll(@org.jetbrains.annotations.NotNull
Upvotes: 4
Views: 6417
Reputation: 201
You have to specify observed entity:
@RawQuery(observedEntities = [Food::class])
See for more: https://developer.android.com/reference/androidx/room/RawQuery#observedEntities()
Upvotes: 20