How to use parameter fields in Room @Query?
You can't pass parameters like that to room. It does not support a full expression language. You have to use primitive types to pass parameters. Like this,
@Query("SELECT * FROM ticket where user_id = :user_id")
LiveData<Ticket> loadFromUser(String user_id);
A simple solution is to create two other functions, one is for user_id
and one is for user
as follows:
@Query("SELECT * FROM ticket where user_id = :user_id")
LiveData<Ticket> loadFromUser(String user_id);
@Transaction
LiveData<Ticket> loadFromUser(User user){
return loadFromUser(user.id);
}