jpa on a Desktop SWING Application

后端 未结 4 1064
庸人自扰
庸人自扰 2021-01-06 03:02

I\'m developping a mono user desktop application using SWING. I had a little experience with this kind of application on which i used the java.sql api and figured out that i

4条回答
  •  佛祖请我去吃肉
    2021-01-06 03:49

    After re-thinking my design, i decided to change it as follows:

    • create a 'permanent' EM when the application starts, and keep it open until the application shutdowns. permanentEM will be used to find/refresh entities when needed (for fetching lazy relationships for example ...).
      In order to ensure an efficient management of memory by the WEAK refrence-mode, i'll avoid to permanently reference permanentEM's managed entities.
    • create a 'temporary' EM to load the 'permanent' data, that are necessary for the start of the application. Once the data loaded close that temporary EM, to detach all the loaded-in-memory data.
    • create a new 'temporary' EM, for each persist/merge/remove transaction, and close it once the transaction commits.

提交回复
热议问题