m43x
m43x

Reputation: 235

Room (AAC): [SQLITE_ERROR] SQL error or missing database (near "group": syntax error)

Following Dao doesn't build in my Android App:

@Dao
interface GroupDao {

    @Insert
    fun insert(group: Group)

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

When I build the project in Android Studio 3 I get the following error on gradle build step:

: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();

If I remove the loadAll function everything works like a charm... What is the problem with this function?

Upvotes: 9

Views: 3301

Answers (1)

CommonsWare
CommonsWare

Reputation: 1006549

GROUP is a reserved keyword in SQLite. You cannot name a table (or anything else) GROUP. Use the tableName property on the @Entity annotation to rename the table to something else, then use that table name in your @Query.

Upvotes: 12

Related Questions