ZeroProcess
ZeroProcess

Reputation: 1221

Room Generic @RawQuery

I create generic BaseDao and wanted to add generic @RawQuery fn, but when build project get error.

interface BaseDao<T> {
     /*...*/

     @RawQuery
     fun findOneBy(query: SupportSQLiteQuery): LiveData<T?>
}

I know room not support generic @Query but I don't know support generic @RawQuery. SO my question: It is possible to create generic @RawQuery?

Upvotes: 0

Views: 168

Answers (1)

Ian Medeiros
Ian Medeiros

Reputation: 1776

It's not possible. Room is just a code generator. You can't generate code from classes that you don't know on compile time.

You will need to annotate on your interface implementations instead.

Upvotes: 3

Related Questions