手机
当前位置:查字典教程网 >编程开发 >安卓软件开发 >Android GreenDao 获取一对多内容实体时候报错:Entity is detached from DAO context 请问是什么原因?
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开发笔记之:Splash的实现详解

Android的Service应用程序组件基本编写方法

自定义TextView跑马灯效果可控制启动/停止/速度/焦点

Android 四种动画效果的调用实现代码

Android消息处理机制Handler

Android控件系列之EditText使用方法

android判断phonegap是否联网且加载super.loadUrl网址

Android中使用Gson解析JSON数据的两种方法

Android内存调试命令

Android Mms之:联系人管理的应用分析

精品推荐
分类导航