Repository navigation
ORMLite Support: release OpenHelperManager? #943
Description
Activity
Your are right, AA should generate a
releaseHelper()call in the anonDestroy()type of method.But it is not easy to implement, because
EComponentHolderdoes not know about this type of methods. @DayS, what are you suggesting? We faced the same problem when i tried to implement@TypedArrayRes, and i could not release the array.Yes, there is an issue on this. But
OrmLiteDaoannotation could be in any enhanced classes (ie:EBean,EService, ...). So we can't rely ononDestroymethod to release this.You are right. Maybe in the generator, we could check that
EComponentHolderis a "destroyable" thing, and if yes, then generate thereleasemethod? And add a JavaDoc that other client is responsible for releasing in other enhanced classes.It seems that @yDelouis created OrmLite handling. @yDelouis, can you look into this?
I didn't create OrmLite handling but I can work on this.
This could be done in combination with #843 so that some
EBeanwould be "destroyable" too.Ok great. Our enhanced components are the following:
@EActivity @EApplication @EBean @EFragment @EProvider @EReceiver @EIntentService @EService @EView @EViewGroupSome of them still does not have
onDestroy(), so you have to handle this. Namely i think onlyViewandViewGrouplack that method, but putting a dao in a View is a not a good solution anyway.What about
EBeanclasses ? In case of singleton there is no issue but for classic bean we should also release theOpenHelperManagerinstance.
We could generate aonDestroy()method in bean and call this method in every class bean from enhances classes handling this event.I did read this issue. We can use the same mechanism to release the instance but, of course, we can't rely on the availability of an
OnDestroyannotated method in the bean.You are right, sorry... I guess then we should just leave releasing to the client, and emphasize that in the JavaDoc: "if there is no OnDestroy(), then release won't be called."
@EViewand@EViewGroupdo not haveonDestroy(), too, so it would not be a unique case.@yDelouis I think we could partially solve this issue for
@EActivity,@EFragment,@EServiceand@EIntentService. The others can wait since that need would need bigger features to implement.1 remaining item
I guess it would be worth mentionting that "rebind" method of a EBean should take care of that as well.
In my scenario, my adapter is an EBean which itself has a injected DAO. When the rebind() is being called, Helper is not released.I also have the same problems. :)
I agree with @WonderCsabo. We cloud partially solve this issue for
@EActivityand others Annotations with onDestroy method. :)Sounds exciting for "Destroyable"! How did they go? Writing? :)
Feel free to contribute it for
@EActivityand co.
For beans, we do not have a clear concept yet.Okay.
Assign to me. I'll try to fix them.
I cannot assign this to you in the GitHub interface, only excilys AA members, but feel to be assigned. :)
I created a PR.
Kindly give us your advice, please. :)
This is now partially fixed: we now release the helper in
@EActivity,@EFragment,@EServiceand@EIntentService. This problem still persists in enhanced classes where there is noonDestroymethod.@yDelouis i just realized
@OrmLiteDaois available in all component annotations. I think we should not allow it in@EViewand@EViewGroup. WDYT?It's quite the same question than removing
Viewsupport from@EBean...On the second thought, we still allow that, because some people are using
Views instead ofFragments.I am closing this issue, because we cannot release the helpers in other components. We can revisit this if we ever implement #843.
In the generated AA class the OpenHelperManager is used to call the method getHelper().
This helper is assigned to a private local member. However, the helper is not released but the ORMLite documentation specifies this should be done in an onDestroy setting.
(see http://ormlite.com/javadoc/ormlite-core/doc-files/ormlite_4.html#Use-With-Android)
How come it isn't released in the generated class?