An Annotation argument must be a compile time constant
The problem is the one stated in the error, you can't have dynamically defined arguments for your @Query
annotation. If you want to define the name of the table somewhere else, use string concatenation. You can do it like this:
@Query("SELECT * FROM " + Table.USER_TABLE)
fun getAll(): List<User>
This is how they do it in this google sample.
You need to escape the String concatenation when using @Value
annotation with the dollar symbol in Kotlin (prepend \
to $
):
@Query("SELECT * FROM \$Table.USER_TABLE")
fun getAll(): List<User>
You should define column name also in data class and access if you want to use columns in queries and access it via this method:
@Query("SELECT * FROM ${Table.USER_TABLE}")