我有
@Entity
public class Tag {
@PrimaryKey(autoGenerate = true)
private long id;
@ColumnInfo(name = "name")
private String name;
@Ignore
private int totalRecords;
}
和
@Query("SELECT *) FROM Tags ORDER BY importance DESC, name ASC")
LiveData<List<Tag>> getAll();
我想从花药表中选择标签数量并将其映射到'totalRecords' 所以,我的查询变成了
@Query("SELECT *, (SELECT count(id) from RecordingAndTags where tagId=t.id) as totalRecords FROM Tags t ORDER BY importance DESC, name ASC")
LiveData<List<Tag>> getAll();
你可能已经猜到它失败了
The query returns some columns [totalRecords] which are not use by com.myapp.entities.Tag. You can use @ColumnInfo annotation on the fields to specify the mapping.
所以我将'totalRecords'修改为
@ColumnInfo(name = "totalRecords")
@Ignore
private int totalRecords;
不幸的是,它也没有用,并且因同样的警告而失败。
我错过了什么吗?我不能实现这个目标吗?
答案 0 :(得分:0)
这似乎不再是1.1.0-beta2