Greendao: Entity Is Detached From Dao Context
I use GreenDAO. But, throws this exception: 'de.greenrobot.dao.DaoException: Entity is detached from DAO context'. In the generated code, i find this code. /** called by internal
Solution 1:
I find solution.
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
Thanks.
Solution 2:
To complete King Wu answer, It's the same probleme when you instantiate your object yourself. To solve the probleme juste set the daoSession to the object
Productproduct=newProduct(null, 1L, categoryId, null);
product.__setDaoSession(MyApplication.getDaoSession());
and after you can do
product.getCategory()
Post a Comment for "Greendao: Entity Is Detached From Dao Context"