| <html><head> |
| <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> |
| <title>9. Closing</title><base href="display"><link rel="stylesheet" type="text/css" href="css/docbook.css"><meta name="generator" content="DocBook XSL-NS Stylesheets V1.76.1"><link rel="home" href="manual.html" title="Apache OpenJPA 2.3 User's Guide"><link rel="up" href="jpa_overview_em.html" title="Chapter 8. EntityManager"><link rel="prev" href="jpa_overview_em_properties.html" title="8. Retrieving Properties Information"><link rel="next" href="jpa_overview_trans.html" title="Chapter 9. Transaction"></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">9. |
| Closing |
| </th></tr><tr><td width="20%" align="left"><a accesskey="p" href="jpa_overview_em_properties.html">Prev</a> </td><th width="60%" align="center">Chapter 8. |
| EntityManager |
| </th><td width="20%" align="right"> <a accesskey="n" href="jpa_overview_trans.html">Next</a></td></tr></table><hr></div><div class="section" title="9. Closing"><div class="titlepage"><div><div><h2 class="title" style="clear: both" id="jpa_overview_em_closing">9. |
| Closing |
| </h2></div></div></div> |
| |
| <a class="indexterm" name="d5e2775"></a> |
| <pre class="programlisting"> |
| public boolean isOpen(); |
| public void close(); |
| </pre> |
| <p> |
| When an <code class="classname">EntityManager</code> is no longer needed, you should |
| call its <code class="methodname">close</code> method. Closing an <code class="classname"> |
| EntityManager</code> releases any resources it is using. The persistence |
| context ends, and the entities managed by the <code class="classname">EntityManager |
| </code> become detached. Any <code class="classname">Query</code> instances the |
| <code class="classname">EntityManager</code> created become invalid. Calling any method |
| other than <code class="methodname">isOpen</code> on a closed <code class="classname">EntityManager |
| </code> results in an <code class="classname">IllegalStateException</code>. You |
| cannot close a <code class="classname">EntityManager</code> that is in the middle of a |
| transaction. |
| </p> |
| <p> |
| If you are in a managed environment using injected entity managers, you should |
| not close them. |
| </p> |
| </div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="jpa_overview_em_properties.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="jpa_overview_em.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="jpa_overview_trans.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">8. |
| Retrieving Properties Information |
| </td><td width="20%" align="center"><a accesskey="h" href="manual.html">Home</a></td><td width="40%" align="right" valign="top"> Chapter 9. |
| Transaction |
| </td></tr></table></div></body></html> |