• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

how to handle Ressource EntityManager and E-M-Factory?

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i'am writing a plain java application with a jpa-db connection. i googled and read about "container-managed" and "application-managed" persistence. i guess in my case of a plain java-application there is no "container"? so i have to managa the resource myself? if so how?

my first idea was to use very local em and emf - instantiated and closed within the methods that interact with db (i made one "db-api-class" on top of the entity classes). the advantag is that all that uses the class don't have to worry about the resource, they don't have to call "close" to free the resources (em and emf and probably transaction?) this class uses. The problem is i have one instance of this resources per instance of the db-api-class?!

my next idea was to have "singleton" fields of this resources (static fields instntiated like singleton classes: if(field==null)..new field)? so what should i do?



thanks in advance
 
And will you succeed? Yes you will indeed! (98 and 3/4 % guaranteed) - Seuss. tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic