Reputation: 75
I am relatively new to Android Development and using its Room persistence library. The problem I am currently facing is the following error:
error: There is a problem with the query: [SQLITE_ERROR] SQL error or missing database (no such column: s_abb)
However my table schema (that this column is being referenced by) does contain this column by this name. Here is how I defined my entity in Android
@Entity
public class stops {
@PrimaryKey
@NonNull
@ColumnInfo(name = "s_name")
private String s_name;
@Ignore
@ColumnInfo(name = "s_abb")
private String s_abb;
@Ignore
@ColumnInfo(name = "Comments")
private String Comments;
public String getS_abb() {
return s_abb;
}
public void setS_abb(String s_abb) {
this.s_abb = s_abb;
}
public String getS_name() {
return s_name;
}
public void setS_name(String s_name) {
this.s_name = s_name;
}
public String getComments() {
return Comments;
}
public void setComments(String comments) {
Comments = comments;
}
}
I have tested the query in SQLite Studio and it does return expected data. Here is a screen shot of query written within DAO Interface: Query. I personally think the main problem is that Room may not recognize the aliases I am using with my subqueries and the column names. Am I correct in thinking this? I hope my screenshot helps. I did make sure to add proper spacing between SQL statements, as many solutions here have pointed out. If any of you need me to provide more information, I am happy to oblige! Thank you
Upvotes: 3
Views: 1814
Reputation: 75
As Vladimir Gladun pointed out, the column s_abb
that I was querying for was set with an @Ignore
annotation over it. Which as Android's documentation on @Ignore
annotations states that "Ignores the marked element from Room's processing logic":
https://developer.android.com/reference/android/arch/persistence/room/Ignore.
Which basically means Room disregards it completely.
However this was not the only problem, My method was expecting Entity
type values
whereas the SELECT
statement from my outermost query was returning String
type values. Fixing those two errors solved my problem.
Upvotes: 2