Skip to content
This repository was archived by the owner on Feb 26, 2023. It is now read-only.
This repository was archived by the owner on Feb 26, 2023. It is now read-only.

ORMLite Support: release OpenHelperManager? #943

Description

@jeffreydelooff

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?

Activity

  1. WonderCsabo commented on Apr 7, 2014

    @WonderCsabo
    Member

    Your are right, AA should generate a releaseHelper() call in the an onDestroy() type of method.

    But it is not easy to implement, because EComponentHolder does 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.

  2. added this to the 3.1 milestone on Apr 22, 2014
  3. DayS commented on Apr 22, 2014

    @DayS
    Contributor

    Yes, there is an issue on this. But OrmLiteDao annotation could be in any enhanced classes (ie: EBean, EService, ...). So we can't rely on onDestroy method to release this.

  4. WonderCsabo commented on Apr 22, 2014

    @WonderCsabo
    Member

    You are right. Maybe in the generator, we could check that EComponentHolder is a "destroyable" thing, and if yes, then generate the release method? 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?

  5. yDelouis commented on Apr 22, 2014

    @yDelouis
    Contributor

    I didn't create OrmLite handling but I can work on this.

    This could be done in combination with #843 so that some EBean would be "destroyable" too.

  6. WonderCsabo commented on Apr 22, 2014

    @WonderCsabo
    Member

    Ok great. Our enhanced components are the following:

    @EActivity
    @EApplication
    @EBean
    @EFragment
    @EProvider
    @EReceiver
    @EIntentService
    @EService
    @EView
    @EViewGroup
    

    Some of them still does not have onDestroy(), so you have to handle this. Namely i think only View and ViewGroup lack that method, but putting a dao in a View is a not a good solution anyway.

  7. DayS commented on Apr 22, 2014

    @DayS
    Contributor

    What about EBean classes ? In case of singleton there is no issue but for classic bean we should also release the OpenHelperManager instance.
    We could generate a onDestroy() method in bean and call this method in every class bean from enhances classes handling this event.

  8. WonderCsabo commented on Apr 22, 2014

    @WonderCsabo
    Member

    @DayS are you read the referenced #843 ? That suggestion would make EBeans destroyable at instance level.

  9. DayS commented on Apr 24, 2014

    @DayS
    Contributor

    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 OnDestroy annotated method in the bean.

  10. WonderCsabo commented on Apr 24, 2014

    @WonderCsabo
    Member

    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." @EView and @EViewGroup do not have onDestroy(), too, so it would not be a unique case.

  11. WonderCsabo commented on Aug 27, 2014

    @WonderCsabo
    Member

    @yDelouis I think we could partially solve this issue for @EActivity, @EFragment, @EService and @EIntentService. The others can wait since that need would need bigger features to implement.

  12. modified the milestones: 3.1, 3.2 on Sep 20, 2014
  13. 1 remaining item

  14. SidhNor commented on Oct 3, 2014

    @SidhNor

    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.

  15. removed this from the 3.2 milestone on Nov 12, 2014
  16. jiongxuan commented on Nov 14, 2014

    @jiongxuan
    Contributor

    I also have the same problems. :)

    I agree with @WonderCsabo. We cloud partially solve this issue for @EActivity and others Annotations with onDestroy method. :)

    Sounds exciting for "Destroyable"! How did they go? Writing? :)

  17. WonderCsabo commented on Nov 14, 2014

    @WonderCsabo
    Member

    Feel free to contribute it for @EActivity and co.
    For beans, we do not have a clear concept yet.

  18. jiongxuan commented on Nov 15, 2014

    @jiongxuan
    Contributor

    Okay.

    Assign to me. I'll try to fix them.

  19. WonderCsabo commented on Nov 15, 2014

    @WonderCsabo
    Member

    I cannot assign this to you in the GitHub interface, only excilys AA members, but feel to be assigned. :)

  20. jiongxuan commented on Nov 16, 2014

    @jiongxuan
    Contributor

    I created a PR.

    Kindly give us your advice, please. :)

  21. WonderCsabo commented on Nov 20, 2014

    @WonderCsabo
    Member

    This is now partially fixed: we now release the helper in @EActivity, @EFragment, @EService and @EIntentService. This problem still persists in enhanced classes where there is no onDestroy method.

  22. WonderCsabo commented on Jun 24, 2015

    @WonderCsabo
    Member

    @yDelouis i just realized @OrmLiteDao is available in all component annotations. I think we should not allow it in @EView and @EViewGroup. WDYT?

  23. yDelouis commented on Jun 24, 2015

    @yDelouis
    Contributor

    It's quite the same question than removing View support from @EBean...

  24. WonderCsabo commented on Jun 24, 2015

    @WonderCsabo
    Member

    On the second thought, we still allow that, because some people are using Views instead of Fragments.

    I am closing this issue, because we cannot release the helpers in other components. We can revisit this if we ever implement #843.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions