Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
moritz mueller
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • 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
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!