I am getting my objects from the web and directly inserting them into ROOM DATABASE
@Entity(tableName = Constants.TABLE_OBJECT_ICONS)
public class ObjectClass {
@PrimaryKey()
@SerializedName("id")
@ColumnInfo(name = Constants.KEY_OBJECT_ID)
@Expose
private Integer id;
@SerializedName("controlUnit")
@ColumnInfo(name = Constants.KEY_CONTROL_UNIT)
@Expose
private String controlUnit;
@SerializedName("isStack")
@ColumnInfo(name = Constants.IS_STACK)
@Expose
private Boolean isStack;
public Boolean getStack() {
return isStack;
}
public void setStack(Boolean stack) {
isStack = stack;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getControlUnit() {
return controlUnit;
}
public void setControlUnit(String controlUnit) {
this.controlUnit = controlUnit;
}
}
Now the problem is, I am inserting Boolen datatype into DB and room is mapping it into 0 and 1, but when I'm trying to fetch data my getStack() methods returns null
UPDATE
Here is the Dao
@Dao
public interface ObjectDao {
@Insert
void insertObject(ObjectClass objectClass);
@Query("DELETE FROM object_icons")
void deleteAllObjects();
@Query("SELECT * FROM object_icons WHERE object_id=:id AND site_id=:siteId")
Single getObjectById(String id, String siteId);
@Query("SELECT object_name FROM object_icons WHERE object_id=:id AND site_id=:siteId")
String getObjectNameById(String id, String siteId);
@Query("SELECT * FROM object_icons WHERE object_keyword=:key AND site_id=:siteId")
ObjectClass getObjectByKey(String key, String siteId);
@Query("SELECT * FROM object_icons WHERE site_id=:siteId")
Single> getObjectIconsList(String siteId);
}
and after taking the Database I opened it into SQLite Online following is the structure of database.