[英]Doesn't the dynamically query the room database support LiveData?
I have read the artical .我已阅读ARTICAL 。
Room supports @RawQuery
annotation to construct queries at run-time, such as Code A. Room 支持
@RawQuery
注解在运行时构造查询,例如 Code A。
If I use Code B, I get Error B when I complie it.如果我使用代码 B,当我编译它时我会得到错误 B。
It seems that @RawQuery
doesn't support to return LiveData
, right? @RawQuery
似乎不支持返回LiveData
,对吗?
Code A代码 A
interface DBVoiceDao{
@RawQuery
fun runtimeQuery(sortQuery: SupportSQLiteQuery): List<MVoice>
...
}
Code B代码 B
interface DBVoiceDao{
@RawQuery
fun runtimeQuery(sortQuery: SupportSQLiteQuery): LiveData<List<MVoice>>
...
}
Error B错误 B
Schema export directory is not provided to the annotation processor so we cannot export the schema. You can either provide `room.schemaLocation` annotation processor argument OR set exportSchema to false.
public abstract class DBVoiceDatabase extends androidx.room.RoomDatabase {
^[WARN] Incremental annotation processing requested, but support is disabled because the following processors are not incremental: androidx.room.RoomProcessor (DYNAMIC).
it does support it, but you have to specify the observed entity, as described here https://developer.android.com/reference/androidx/room/RawQuery example:它确实支持它,但您必须指定观察到的实体,如下所述https://developer.android.com/reference/androidx/room/RawQuery示例:
@Dao
interface RawDao {
@RawQuery(observedEntities = Song.class)
LiveData<List<Song>> getSongs(SupportSQLiteQuery query);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.