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?
Error Message SQL ERROR: syntax error at or near. Troubleshooting This should generally be the first step to troubleshoot any SQL syntax error in a large query: iteratively comment out blocks of SQL to narrow down where the problem is. TIP: To make this process easier, change the group by clause to use position references
In some circumstances, the database error message may display extra detail about where the error was raised, which can be helpful in narrowing down where to look. This should generally be the first step to troubleshoot any SQL syntax error in a large query: iteratively comment out blocks of SQL to narrow down where the problem is.
An object does not exist in the database or is not accessible from the current query (eg referencing orders.id when there is no orders table joined in the current query, etc) In some circumstances, the database error message may display extra detail about where the error was raised, which can be helpful in narrowing down where to look.
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
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With