Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #32360

Why save the EntityManagerFactory

From Cecil Westerhof <Cecil@decebal.nl>
Newsgroups comp.lang.java.programmer
Subject Why save the EntityManagerFactory
Date 2015-08-19 12:32 +0200
Organization Decebal Computing
Message-ID <87a8tnr2kq.fsf@Equus.decebal.nl> (permalink)

Show all headers | View raw


I am using http://www.uow.edu.au/~nabg/399/JPA/JPA.pdf to get a start
with JPA. When looking at page 14 an EntityManagerFactory is created
and kept until the end of the program.
Could the following:
    emf = Persistence.createEntityManagerFactory("JavaApplication12PU");
    em = emf.createEntityManager();
not just be changed to:
    em = Persistence.createEntityManagerFactory("JavaApplication12PU").createEntityManager();

-- 
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof

Back to comp.lang.java.programmer | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

Why save the EntityManagerFactory Cecil Westerhof <Cecil@decebal.nl> - 2015-08-19 12:32 +0200
  Re: Why save the EntityManagerFactory Arne Vajhøj <arne@vajhoej.dk> - 2015-08-19 19:15 -0400
  Re: Why save the EntityManagerFactory Eternal Hope <laughingspam99@gmail.com> - 2015-08-21 09:43 +0100
    Re: Why save the EntityManagerFactory Arne Vajhøj <arne@vajhoej.dk> - 2015-08-30 21:55 -0400
      Re: Why save the EntityManagerFactory Lew <lewbloch@gmail.com> - 2015-08-31 10:13 -0700

csiph-web