小编Tus*_*rma的帖子

DAO错误:-参数的类型必须是用@Entity注释的类或其集合/数组

我是 Android 开发新手,我正在尝试通过遵循 Android 架构组件来制作一个笔记应用程序,但在运行时,我在 DAO 中遇到错误,如果有人可以提供帮助,我将不胜感激。这是我收到的代码和错误。

我收到的错误

道:-

'''

@Dao
interface NoteDao {
    @Insert(onConflict = OnConflictStrategy.IGNORE)
    suspend fun insert(note :Note)

    @Delete
    suspend fun delete(note : Note)

    @Query("SELECT * FROM Notes_table order by id")
    fun getALL(): LiveData<List<Note>>

    @Query("SELECT * From Notes_table where id= :pos")
    fun getSpecific(pos :Int):Note

}
Run Code Online (Sandbox Code Playgroud)

'''

实体:-

'''

@Entity(tableName = "Notes_table")
data class Note(@ColumnInfo(name="noteText") val text:String) {
    @PrimaryKey(autoGenerate = true) var id:Int =0

}
Run Code Online (Sandbox Code Playgroud)

''' 数据库:-

'''

@Database(entities = [Note::class],version = 1,exportSchema = false)
abstract class NoteDatabase : …
Run Code Online (Sandbox Code Playgroud)

android kotlin data-access-object android-room android-architecture-components

6
推荐指数
1
解决办法
4672
查看次数