| <html><head> |
| <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> |
| <title>Chapter 7. EntityManagerFactory</title><base href="display"><link rel="stylesheet" type="text/css" href="css/docbook.css"><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"><link rel="home" href="manual.html" title="Apache OpenJPA 2.4 User's Guide"><link rel="up" href="jpa_overview.html" title="Part 2. Java Persistence API"><link rel="prev" href="jpa_overview_persistence_use.html" title="2. Non-EE Use"><link rel="next" href="jpa_overview_emfactory_em.html" title="2. Obtaining EntityManagers"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter 7. |
| EntityManagerFactory |
| </th></tr><tr><td width="20%" align="left"><a accesskey="p" href="jpa_overview_persistence_use.html">Prev</a> </td><th width="60%" align="center">Part 2. Java Persistence API</th><td width="20%" align="right"> <a accesskey="n" href="jpa_overview_emfactory_em.html">Next</a></td></tr></table><hr></div><div class="chapter" id="jpa_overview_emfactory"><div class="titlepage"><div><div><h2 class="title">Chapter 7. |
| EntityManagerFactory |
| </h2></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl class="toc"><dt><span class="section"><a href="jpa_overview_emfactory.html#jpa_overview_emfactory_obtain">1. |
| Obtaining an EntityManagerFactory |
| </a></span></dt><dt><span class="section"><a href="jpa_overview_emfactory_em.html">2. |
| Obtaining EntityManagers |
| </a></span></dt><dt><span class="section"><a href="jpa_overview_emfactory_perscontext.html">3. |
| Persistence Context |
| </a></span></dt><dd><dl><dt><span class="section"><a href="jpa_overview_emfactory_perscontext.html#jpa_overview_emfactory_perscontext_trans">3.1. |
| Transaction Persistence Context |
| </a></span></dt><dt><span class="section"><a href="jpa_overview_emfactory_perscontext.html#jpa_overview_emfactory_perscontext_extend">3.2. |
| Extended Persistence Context |
| </a></span></dt></dl></dd><dt><span class="section"><a href="jpa_overview_emf_properties.html">4. |
| Retrieving Properties Information |
| </a></span></dt><dt><span class="section"><a href="jpa_overview_emfactory_close.html">5. |
| Closing the EntityManagerFactory |
| </a></span></dt><dt><span class="section"><a href="jpa_overview_emfactory_puutil.html">6. |
| PersistenceUnitUtil |
| </a></span></dt></dl></div> |
| |
| <a class="indexterm" name="d5e2106"></a> |
| <div class="mediaobject"><table border="0" summary="manufactured viewport for HTML img" style="cellpadding: 0; cellspacing: 0;" width="279"><tr><td><img src="img/entitymanagerfactory.png"></td></tr></table></div> |
| <p> |
| The <code class="classname">EntityManagerFactory</code> creates <code class="classname"> |
| EntityManager</code> instances for application use. |
| </p> |
| <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3> |
| <p> |
| OpenJPA extends the standard <code class="classname">EntityManagerFactory</code> |
| interface with the |
| <a class="ulink" href="../javadoc/org/apache/openjpa/persistence/OpenJPAEntityManagerFactory.html" target="_top"> |
| <code class="classname">OpenJPAEntityManagerFactory</code></a> to provide additional |
| functionality. |
| </p> |
| </div> |
| <div class="section" id="jpa_overview_emfactory_obtain"><div class="titlepage"><div><div><h2 class="title" style="clear: both">1. |
| Obtaining an EntityManagerFactory |
| </h2></div></div></div> |
| |
| <a class="indexterm" name="d5e2121"></a> |
| <a class="indexterm" name="d5e2124"></a> |
| <a class="indexterm" name="d5e2127"></a> |
| <p> |
| Within a container, you will typically use <span class="emphasis"><em>injection</em></span> to |
| access an <code class="classname">EntityManagerFactory</code>. There are, however, |
| alternative mechanisms for <code class="classname">EntityManagerFactory</code> |
| construction. |
| </p> |
| <p> |
| Some vendors may supply public constructors for their <code class="classname"> |
| EntityManagerFactory</code> implementations, but we recommend using the |
| Java Connector Architecture (JCA) in a managed environment, or the <code class="classname"> |
| Persistence</code> class' <code class="methodname">createEntityManagerFactory |
| </code> methods in an unmanaged environment, as described in |
| <a class="xref" href="jpa_overview_persistence.html" title="Chapter 6. Persistence">Chapter 6, <i> |
| Persistence |
| </i></a>. These strategies allow |
| vendors to pool factories, cutting down on resource utilization. |
| </p> |
| <p> |
| <a class="indexterm" name="d5e2139"></a> |
| JPA allows you to create and configure an <code class="classname"> |
| EntityManagerFactory</code>, then store it in a Java Naming and Directory |
| Interface (JNDI) tree for later retrieval and use. |
| </p> |
| </div> |
| |
| |
| |
| |
| |
| |
| |
| |
| </div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="jpa_overview_persistence_use.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="jpa_overview.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="jpa_overview_emfactory_em.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">2. |
| Non-EE Use |
| </td><td width="20%" align="center"><a accesskey="h" href="manual.html">Home</a></td><td width="40%" align="right" valign="top"> 2. |
| Obtaining EntityManagers |
| </td></tr></table></div></body></html> |