kartikay mahajan
kartikay mahajan

Reputation: 1

Unable to solve error: Type of the parameter must be a class annotated with @Entity or a collection/array of it

please check what's the error. Thanks in advance.

@Dao
interface FavDishDao {

    @Insert
    suspend fun insertFavDishDetails(favDish: FavDish)

   
    @Query("SELECT * FROM FAV_DISHES_TABLE ORDER BY ID")
    fun getAllDishesList(): Flow<List<FavDish>>

    @Update
    suspend fun updateFavDishDetails(favDish: FavDish)

    @Query("SELECT * FROM FAV_DISHES_TABLE WHERE favorite_dish = 1")
    fun getFavoriteDishesList(): Flow<List<FavDish>>
}

Upvotes: 0

Views: 1428

Answers (3)

Andy
Andy

Reputation: 810

I was able to resolve a kind of similar issue downgrading the Kotlin version to "1.4.32"

Upvotes: 1

Tushar Verma
Tushar Verma

Reputation: 183

If You have annotated your entity and instantiated database properly then this is actually the same problem I faced just go to your build.gradle(app) file and there you could see warnings in you dependencies(highlighted in yellow). Press ctrl+alt+shift+s(basically the open option) then go to dependencies(as shown in the image below) and then one by one on all your dependencies check whether there is an update variable option available in the details part if yes click on that. Once you are done with all of them click apply after that click ok and that would sync your gradle.

Now try to run your app.

PS:-As others have suggested try to be a little more descriptive with your question the next time.

enter image description here

Upvotes: 1

Praveen
Praveen

Reputation: 3486

You have to annotate your data class FavDish with @Entity(tableName="FAV_DISHES_TABLE") for creating a table for this data class in your Room database.

Upvotes: 0

Related Questions