| <html><head> |
| <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> |
| <title>Chapter 8. EntityManager</title><link rel="stylesheet" href="css/docbook.css" type="text/css"><base href="display"><meta name="generator" content="DocBook XSL Stylesheets V1.72.0"><link rel="start" href="manual.html" title="Apache OpenJPA 2.1 User's Guide"><link rel="up" href="jpa_overview.html" title="Part 2. Java Persistence API"><link rel="prev" href="jpa_overview_emfactory_puutil.html" title="6. PersistenceUnitUtil"><link rel="next" href="jpa_overview_em_lifecycle.html" title="2. Entity Lifecycle Management"></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 8. |
| EntityManager |
| </th></tr><tr><td width="20%" align="left"><a accesskey="p" href="jpa_overview_emfactory_puutil.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_em_lifecycle.html">Next</a></td></tr></table><hr></div><div class="chapter" lang="en" id="jpa_overview_em"><div class="titlepage"><div><div><h2 class="title"><a name="jpa_overview_em"></a>Chapter 8. |
| EntityManager |
| </h2></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="section"><a href="jpa_overview_em.html#jpa_overview_em_trans">1. |
| Transaction Association |
| </a></span></dt><dt><span class="section"><a href="jpa_overview_em_lifecycle.html">2. |
| Entity Lifecycle Management |
| </a></span></dt><dt><span class="section"><a href="jpa_overview_em_lifeexamples.html">3. |
| Lifecycle Examples |
| </a></span></dt><dt><span class="section"><a href="jpa_overview_em_identity.html">4. |
| Entity Identity Management |
| </a></span></dt><dt><span class="section"><a href="jpa_overview_em_cache.html">5. |
| Cache Management |
| </a></span></dt><dt><span class="section"><a href="jpa_overview_em_query.html">6. |
| Query Factory |
| </a></span></dt><dt><span class="section"><a href="jpa_overview_em_properties.html">7. |
| Retrieving Properties Information |
| </a></span></dt><dt><span class="section"><a href="jpa_overview_em_closing.html">8. |
| Closing |
| </a></span></dt></dl></div><a class="indexterm" name="d0e4810"></a><div class="mediaobject"><table border="0" summary="manufactured viewport for HTML img" cellspacing="0" cellpadding="0" width="189"><tr><td><img src="img/entitymanager.png"></td></tr></table></div><p> |
| The diagram above presents an overview of the <code class="classname">EntityManager |
| </code> interface. For a complete treatment of the <code class="classname"> |
| EntityManager</code> API, see the |
| <a xmlns:xlink="http://www.w3.org/1999/xlink" href="http://java.sun.com/javaee/6/docs/api/javax/persistence/EntityManager.html" target="_top"> |
| Javadoc</a> documentation. Methods whose parameter signatures consist of |
| an ellipsis (...) are overloaded to take multiple parameter types. |
| </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">EntityManager</code> interface with |
| the |
| <a xmlns:xlink="http://www.w3.org/1999/xlink" href="../javadoc/org/apache/openjpa/persistence/OpenJPAEntityManager.html" target="_top"> |
| <code class="classname">org.apache.openjpa.persistence.OpenJPAEntityManager</code> |
| </a> interface to provide additional functionality. |
| </p></div><p> |
| The <code class="classname">EntityManager</code> is the primary interface used by |
| application developers to interact with the JPA runtime. The methods |
| of the <code class="classname">EntityManager</code> can be divided into the following |
| functional categories: |
| </p><div class="itemizedlist"><ul type="disc"><li><p> |
| <code class="classname">Transaction</code> association. |
| </p></li><li><p> |
| Entity lifecycle management. |
| </p></li><li><p> |
| Entity identity management. |
| </p></li><li><p> |
| Cache management. |
| </p></li><li><p> |
| <code class="classname">Query</code> factory. |
| </p></li><li><p> |
| Closing. |
| </p></li></ul></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="jpa_overview_em_trans"></a>1. |
| Transaction Association |
| </h2></div></div></div><a class="indexterm" name="d0e4876"></a><a class="indexterm" name="d0e4883"></a><pre class="programlisting"> |
| public EntityTransaction getTransaction(); |
| </pre><p> |
| Every <code class="classname">EntityManager</code> has a one-to-one relation with an |
| <a href="jpa_overview_trans.html" title="Chapter 9. Transaction"><code class="classname">EntityTransaction</code> |
| </a> instance. In fact, many vendors use a single class to implement both the |
| <code class="classname">EntityManager</code> and <code class="classname">EntityTransaction |
| </code> interfaces. If your application requires multiple concurrent |
| transactions, you will use multiple <code class="classname">EntityManager</code>s. |
| </p><p> |
| You can retrieve the <code class="classname">EntityTransaction</code> associated with an |
| <code class="classname">EntityManager</code> through the <code class="methodname">getTransaction |
| </code> method. Note that most JPA implementations can |
| integrate with an application server's managed transactions. If you take |
| advantage of this feature, you will control transactions by declarative |
| demarcation or through the Java Transaction API (JTA) rather than through the |
| <code class="classname">EntityTransaction</code>. |
| </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_emfactory_puutil.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_em_lifecycle.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">6. |
| PersistenceUnitUtil |
| </td><td width="20%" align="center"><a accesskey="h" href="manual.html">Home</a></td><td width="40%" align="right" valign="top"> 2. |
| Entity Lifecycle Management |
| </td></tr></table></div></body></html> |