android数据库boolean,android - Boolean Query In Room Database - Stack Overflow

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.

5a1db6b1563af494d32b83abed7b84c5.png

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值