Here is a sample POJO
public class Product{
private long id;
private String name;
private double price;
... constructor for all fields
... getters and setters
}
Now, in my productDAO if I have a query like this
@Query(select id, name from products)
LiveData<List<Product>> getProducts()
I get an error like:
The columns returned by the query does not have the fields [price] in ... Product even though they are annotated as non-null or primitive. Columns returned by the query: [id,name]
a) If I go in my Products and set
@Nullable
private double price;
the error remains.
b) If I go in my Products and set
@Ignore
private double price;
the error goes away but if I have another query for instance
@Query(select p.id, p.name, p.price, t.someField from products p inner join table t)
LiveData<List<Product>> getJoinQueryResponse()
because @Ignore
is set the price is returned as 0.0.
So how to solve this? Hopefully I don't need to make a POJO for each different response from room...