The problem is that the query returns all columns except 'id'
I use fts4 and in docs it says:
FTS-enabled tables always use a primary key of type INTEGER and with the column name "rowid". If your FTS-table-backed entity defines a primary key, it must use that type and column name.
here is my entity class:
@Fts4
@Entity(tableName = "projects")
public class Project {
@ColumnInfo(name = "rowid")
@PrimaryKey(autoGenerate = true)
private int id;
private String name;
@ColumnInfo(name = "start_date")
private String startDate;
@ColumnInfo(name = "end_date")
private String endDate;
private String description;
@ColumnInfo(name = "icon_path")
private String iconPath;
private long budget;
public Project(String name, String startDate, String endDate, String description, String iconPath, long budget) {
this.name = name;
this.startDate = startDate;
this.endDate = endDate;
this.description = description;
this.iconPath = iconPath;
this.budget = budget;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getStartDate() {
return startDate;
}
public void setStartDate(String startDate) {
this.startDate = startDate;
}
public String getEndDate() {
return endDate;
}
public void setEndDate(String endDate) {
this.endDate = endDate;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getIconPath() {
return iconPath;
}
public void setIconPath(String iconPath) {
this.iconPath = iconPath;
}
public long getBudget() {
return budget;
}
public void setBudget(long budget) {
this.budget = budget;
}
and here is my simple query:
@Query("SELECT * FROM projects")
public LiveData<List<Project>> getAllProjectsI);
I got a warning :
app.aarsham.projeno.data.Model.Project has some fields [rowid] which are not returned by the query. If they are not supposed to be read from the result, you can mark them with @Ignore annotation. You can suppress this warning by annotating the method with @SuppressWarnings(RoomWarnings.CURSOR_MISMATCH). Columns returned by the query: name, start_date, end_date, description, icon_path, budget. Fields in app.aarsham.projeno.data.Model.Project: rowid, name, start_date, end_date, description, icon_path, budget.
and an error:
The columns returned by the query does not have the fields [id] in app.aarsham.projeno.data.Model.Project even though they are annotated as non-null or primitive. Columns returned by the query: [name,start_date,end_date,description,icon_path,budget]
can anyone help about this?
rowid
column from the entity resolved the error. I hope it would be of your help. – hkurokawa