Having a difficult time finding this answer and the documentation doesn't seem to answer the question. If I have a basic ROOM query,
@Query("SELECT * FROM geotable WHERE geohash = :geohash")
abstract suspend fun getGeoTable(geohash: String) : GeoTable
and there is no such item that uses this primary key, what happens? Android studio says that the DAO object will never return a null. It seems that EmptyResultSetException only gets thrown when you have Single using RxJava which I am not using. So what does plain old ROOM throw when it finds nothing?
Based on the documentation a fruitless query's behavior is defined by the declared return type:
fun func(foo: Foo): Bar
would throw a EmptyResultSetException
fun func(foo: Foo): Bar?
would return null
fun func(foo: Foo): List<Bar>
would return an empty listIf nothing is found based on your criteria, it will return null.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With