Android GreenDao 获取一对多内容实体时候报错:Entity is detached from DAO context 请问是什么原因?
摘要:功能:列表中选择分类,然后获取与该类别关联的对象List,添加到数据源中,再刷新ListView。de.greenrobot.dao.Dao...
功能: 列表中选择分类,然后获取与该类别关联的对象List,添加到数据源中,再刷新ListView。
de.greenrobot.dao.DaoException: Entity is detached from DAO context
在拿到自己1对多的实体内容的时候,会报出该异常。第一次是没问题的。
/** To-many relationship, resolved on first access (and after reset). Changes to to-many relations are not persisted, make changes to the target entity. */
public List< CasesFormInfo > getCasesFormInfoList() {
if (casesFormInfoList == null) {
if (daoSession == null) {
throw new DaoException("Entity is detached from DAO context");
}
CasesFormInfoDao targetDao = daoSession.getCasesFormInfoDao();
List< CasesFormInfo > casesFormInfoListNew = targetDao._queryCasesFormCategoryInfo_CasesFormInfoList(paramid);
synchronized (this) {
if(casesFormInfoList == null) {
casesFormInfoList = casesFormInfoListNew;
}
}
}
return casesFormInfoList;
} 求指点!感激不尽!
回复讨论(解决方案)
解决了吗?我最近在用,碰到同样的问题了
【Android GreenDao 获取一对多内容实体时候报错:Entity is detached from DAO context 请问是什么原因?】相关文章:
★ android MVC中如何在在controller中进行页面跳转(到其他Activity)
★ 自定义TextView跑马灯效果可控制启动/停止/速度/焦点
★ Android定制RadioButton样式三种实现方法