Path: csiph.com!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Cecil Westerhof Newsgroups: comp.lang.java.programmer Subject: Why save the EntityManagerFactory Date: Wed, 19 Aug 2015 12:32:21 +0200 Organization: Decebal Computing Lines: 13 Message-ID: <87a8tnr2kq.fsf@Equus.decebal.nl> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mx02.eternal-september.org; posting-host="528adfd6ad074c92fdc6a7f8fb9e23d8"; logging-data="15928"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18z8qlAylCFJAuWDYTcoxvTY+fYT8G1vd8=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) X-Homepage: http://www.decebal.nl/ Cancel-Lock: sha1:IO9zp5UqXKYFMO2Tujz4O+65sj4= sha1:ndd2MZepJ+5cj6Hwm6aLVpgLpwo= Xref: csiph.com comp.lang.java.programmer:32360 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