When building the room, there are several small problems. Record them. Basically, it is a configuration problem:
There is a problem with the query: [SQLITE_ERROR] SQL error or missing database (no such table: simple_student)。
an error is reported during compilation and the table cannot be found
you need to set the corresponding indication in the declared entity.
//Wrong @Entity data class StudentEntity //Right @Entity(tableName = "student_table") data class StudentEntity
Not sure how to convert a Cursor to this method’s return type (kotlinx.coroutines.flow.Flow<?extends java.util.List<com.zxf.jetpackrelated.room.liveDataOrFlow.StudentEntity>>).
When the Dao layer declares the return value as livedata, an error is reported. After a long investigation, it was found that the corresponding function was declared as a suspended function
correct use should remove the corresponding suspend modifier.
//Wrong @Query("select * from $STUDENT_TABLE_NAME") suspend fun obtainStudentAll(): LiveData<List<StudentEntity>> //Right @Query("select * from $STUDENT_TABLE_NAME") fun obtainStudentAll(): LiveData<List<StudentEntity>>
Not sure how to convert a Cursor to this method’s return type (androidx.lifecycle.LiveData<java.util.List<com.zxf.jetpackrelated.room.liveDataOrFlow.StudentEntity>>)
Similarly, it cannot be converted to flow, and the corresponding suspend modifier is removed.
//Wrong @Query("select * from $STUDENT_TABLE_NAME") suspend fun obtainStudentAll(): Flow<List<StudentEntity>> //Right @Query("select * from $STUDENT_TABLE_NAME") fun obtainStudentAll(): Flow<List<StudentEntity>>
If you do not need to declare the return type as livedata or flow, you can directly declare suspend.
- [Solved] Android Room: Database Common Error ‘missing database’
- SSH integration error: org.hibernate.hql.internal.ast.QuerySyntaxException: User is not mapped[……]
- Solution of Hibernate paging report only entering result set and not supporting requested operation
- Uncaught Error: Error calling method on NPObject.
- [Fixed]ERROR: canceling statement due to conflict with recovery
- ORA-08103: object no longer exists [How to Solve]
- [Solved] ibatis.builder.BuilderException: Error parsing Mapper XML: Could not resolve type alias ‘XXX‘
- TypeError: res.render is not a function
- How to Fix error: conversion from “” to non-scalar type “”
- Mysql184.108.40.206 Error 1054 (42S22): Unknown Column’password’ In’field List’ When Changing User Password
- ElementUI Error in callback for watcher “data”: “Error: [ElTable] prop row-key is required”
- How to Solve Expdp Error ORA-39126
- [Solved] ora 01033 linux,ORA-01033: ORACLE initialization or shutdown in progres
- 500 (International server error) server error in Flash + heroku
- [Solved] Uncaught ReferenceError: FileAsyncWriter is not defined
- Java.sql.SQLException: ORA-02291: integrity constraint violated – par
- How to Solve PageHelper.startPage count Error
- [Solved] Conversion not supported for type java.time.LocalDateTime
- [Solved] dhl: Error: LINQ to Entities does not support the specified type member “Date”
- How to Solve ES error: “illegal_argument_exception”