android - 房间 (AAC) : [SQLITE_ERROR] SQL error or missing database (near "group": syntax error)

标签 android kotlin android-room

Following Dao 没有在我的 Android 应用中构建:

@Dao
interface GroupDao {

    @Insert
    fun insert(group: Group)

    @Query("SELECT * FROM group")
    fun loadAll(): LiveData<List<Group>>
}

当我在 Android Studio 3 中构建项目时,我在 gradle 构建步骤中收到以下错误:

:app:kaptDebugKotlin

e: C:\workspaces\SystemicConsensusKotlin\app\build\tmp\kapt3\stubs\debug\de\maxdobler\systemicconsensus\group\GroupDao.java:13: error: There is a problem with the query: [SQLITE_ERROR] SQL error or missing database (near "group": syntax error)

e: public abstract android.arch.lifecycle.LiveData> loadAll();

如果我删除 loadAll 函数,一切都会像魅力一样工作...... 这个函数有什么问题?

最佳答案

GROUPreserved keyword in SQLite .你不能命名一个表(或其他任何东西)GROUP。使用 @Entity 注释上的 tableName 属性将表重命名为其他名称,然后在 @Query 中使用该表名。

关于android - 房间 (AAC) : [SQLITE_ERROR] SQL error or missing database (near "group": syntax error),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45623354/

相关文章:

spring-boot - 是否可以在一个事务中使用 MinIO 客户端保存一组文件?

Android onRequestPermissionsResult 未在 fragment 中调用

android - Kotlin Room 数据库单例模式

android - 如何使用列表大小与 Room 数据库返回的列表大小不同的 AAC 分页库

android - 无法从 Activity :android 发送广播

android - 滚动 ListView 时出现内存不足异常?

javascript - 在Jquery Mobile + Android Webview的视频缩略图上方插入播放按钮(图像)

Reactive SQL 客户端 (Quarkus/Vert.X) 中的 Kotlin 协程事务

android - 如何在 RoomDatabase 中存储 Enum 的 ArrayList

android - 如何在android虚拟键盘顶部设置 'A RenderFlex overflowed by 61 pixels on the bottom.'