I am developing an Android app using the Room persistence library. I have a User and a Car entity
@Entity(tableName = \"users\")
public class User {
@Primar
Change your query:
@Query("SELECT * FROM users JOIN cars ON users.id = cars.userId")
to specify the columns in the POJO class UserWithCar. The columns returned must match all the columns, and have the same column name as your POJO. You can use AS to change the column names in the query.
@Query("SELECT userId as userId , brand as brand FROM users JOIN cars ON users.id = cars.userId")
Alternatively, you can use @ColumnInfo to specify the column name mappings.