I have a class entity as below
@Entity
public class Task {
private String name;
private Integer ParentId;
private Integer userId;
@Ignore
private int noOfSubTask;
}
in DAO class there is a method getTaskList()
@Dao
public interface TaskDao extends Dao<Task> {
@Query("SELECT *,(SELECT count(*) FROM Task b WHERE a._id = b.ParentId ) AS noOfSubTask FROM Task a ")
LiveData<List<Task>> getTaskList();
}
I want to fill noOfSubTask with the number given by (SELECT count(*) FROM Task b WHERE a._id = b.ParentId ) portion of query, but problem is it is not a column so room library does not map it getTaskList method in dao implementation (auto-generated) class.
Is there any way to fill non column field of entity (like noOfSubTask in my case) using any method of dao class of room library?