无法使用Android Room Persistence库在DatabaseView上执行搜索

时间:2019-03-04 15:10:19

标签: android android-room

嗨,Android开发人员,

我正在尝试使用新版本的Android Room创建DatabaseView并在DBView上执行搜索,但是DAO找不到任何结果,即使我键入非常明显的查询也是如此。

这是我的Room Gradle依赖项的版本。

  //Android Room
def room_version = "2.1.0-alpha04"
implementation "androidx.room:room-runtime:$room_version"
kapt "androidx.room:room-compiler:$room_version"

这是我的DatabaseView

@DatabaseView("SELECT  * from popular UNION SELECT * from trending UNION SELECT * from favorite",
        viewName = "searchView")
data class SeriesEntity(
        @PrimaryKey
        var id: Int? = null,
        var originalName: String? = null,
        var name: String? = null,
        var popularity: Double? = null,
        var voteCount: Int? = null,
        var voteAverage: Double? = null,
        var firstAirDate: String? = null,
        var posterPath: String? = null,
        var genreIds: List<Int>? = null,
        var originalLanguage: String? = null,
        var backdropPath: String? = null,
        var overview: String? = null,
        var originCountry: List<String>? = null
)

这是我的DAO:

    @Dao
interface SearchSeriesDao {
    @Query("""
        SELECT * FROM searchView WHERE name MATCH :query """)
    fun query(query : String) : LiveData<List<SeriesEntity>>
}

我的主要数据库类:

@Database(entities =
    arrayOf(
        FavoritesEntity::class,
        PopularEntity::class,
        TrendingEntity::class),
        views = arrayOf(SeriesEntity::class), version = 5)

每次我尝试使用DAO在视图中搜索简单记录时,返回的LiveData为空。

0 个答案:

没有答案