I have 3 entitites (Location, Current and Forecast) with following relationships:
1.) Location - Current (one-one)
2.) Location - Forecast (one-one)
Now to retrieve data from it i wrote a query
@Transaction
@Query(
"SELECT weather_location.id, name, current_weather.*, weather_forecast.* FROM weather_location " +
"INNER JOIN current_weather ON current_weather.locationId = weather_location.id " +
"INNER JOIN weather_forecast ON weather_forecast.locationId = weather_location.id "
)
fun getWeather(): Flow<List<WeatherModel>>
WeatherModel:
data class WeatherModel(
val id: String,
val name: String,
@Relation(
parentColumn = "id", <- line 12
entityColumn = "locationId"
)
val currentWeather: CurrentWeatherEntity,
@Relation(
parentColumn = "id",
entityColumn = "locationId"
)
val weatherForecast: WeatherForecastEntity
)
Error:
java.lang.NullPointerException: Parameter specified as non-null is null: method com.anshtya.weatherapp.data.local.model.WeatherModel.<init>, parameter currentWeather
at com.anshtya.weatherapp.data.local.model.WeatherModel.<init>(Unknown Source:12)
at com.anshtya.weatherapp.data.local.dao.WeatherDao_Impl$16.call(WeatherDao_Impl.java:609)
at com.anshtya.weatherapp.data.local.dao.WeatherDao_Impl$16.call(WeatherDao_Impl.java:568)
Why i am getting this error? Note: Query works in App Inspection of Android Studio