本文介绍了GreenDAO:实体从DAO背景分离的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我用GreenDAO。但是,引发此异常:
I use GreenDAO. But, throws this exception:
"de.greenrobot.dao.DaoException: Entity is detached from DAO context".
在生成的code,我觉得这是code。
In the generated code, i find this code.
/** called by internal mechanisms, do not call yourself. */
public void __setDaoSession(DaoSession daoSession) {
this.daoSession = daoSession;
myDao = daoSession != null ? daoSession.getPeerGroupDao() : null;
}
任何人都知道,当GreenDAO打电话吗?此外,如何触发它来调用。
Anyone know when the GreenDAO call it? Also, how to trigger it to call.
感谢。
推荐答案
我找到解决办法。
该greenDAO通话__setDaoSession内部,当你调用loadDeep和queryDeep。调用这些方法后,一对多或一对一的关系建立起来了。如果你只是使用SQLiteDatabase来查询你的结果,你只要让你的数据,但关系并没有建立起来。
The greenDAO call __setDaoSession internally when you call loadDeep and queryDeep. After calling these method, the one to many or one to one relation is built up. If you just use SQLiteDatabase to query your result, you just get your data but the relationship is not built up.
在细节,你可以去这个
In detail, you can go this site
感谢。
这篇关于GreenDAO:实体从DAO背景分离的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!