如果没有可用结果,房间将返回IndexOutOfBoundException

时间:2019-10-09 13:48:51

标签: android android-sqlite android-room

我已经在会议室中定义了此功能:

import androidx.room.Dao
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Quer


@Dao
interface PlaceDao {

@Query("SELECT * from place_table")
suspend fun getAllPlaces(): List<Place>

// This query throws IndexOutOfBoundsException 
@Query("SELECT * FROM place_table WHERE masterId IN (:guid)")
suspend fun getPlacesByGuids(guid: List<String>): List<Place>?

}

但是,每当我调用getPlacesByGuids传递的Guid列表在place_table中没有可用的位置时,而不是返回空列表或null,它会抛出IndexOutOfBoundException。另一方面,getAllPlaces似乎工作正常,即使place_table中没有任何内容,也不会导致异常。对我在这里缺少什么有任何想法吗?

0 个答案:

没有答案