Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #32376
| From | Arne Vajhøj <arne@vajhoej.dk> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: Why save the EntityManagerFactory |
| Date | 2015-08-19 19:15 -0400 |
| Organization | Aioe.org NNTP Server |
| Message-ID | <mr32n2$9aq$2@speranza.aioe.org> (permalink) |
| References | <87a8tnr2kq.fsf@Equus.decebal.nl> |
On 8/19/2015 6:32 AM, Cecil Westerhof wrote:
> 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();
If emf is not used later then I can not see any point.
In Java EE context you would typical let the container inject what you need.
Arne
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll 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