org.greenrobot.greendao.DaoException: Entity is detached from DAO context
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2986)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3017)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2392)
at android.app.ActivityThread.access$800(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
Caused by: org.greenrobot.greendao.DaoException: Entity is detached from DAO context
at
key entity
class Recipe {
private String stepContent;
@ToMany(referencedJoinProperty = "recipeId")
private List<FoodMaterial> foodMaterialList;
@Generated(hash = 1718473014)
public List<FoodMaterial> getFoodMaterialList() {
if (foodMaterialList == null) {
final DaoSession daoSession = this.daoSession;
if (daoSession == null) {
throw new DaoException("Entity is detached from DAO context");
}
FoodMaterialDao targetDao = daoSession.getFoodMaterialDao();
List<FoodMaterial> foodMaterialListNew = targetDao
._queryRecipe_FoodMaterialList(id);
synchronized (this) {
if (foodMaterialList == null) {
foodMaterialList = foodMaterialListNew;
}
}
}
return foodMaterialList;
}
}
example code
mRecipe.getFoodMaterialList(), when i try to get the foodMaterialList by recipe object, throw the exception in getFoodMaterialList(), tell me daoSession is null ..thats why?
version 3.2.0
stack trace
key entity
mRecipe.getFoodMaterialList()
, when i try to get the foodMaterialList by recipe object, throw the exception in getFoodMaterialList(), tell me daoSession is null ..thats why?