| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" |
| "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> |
| <head> |
| <meta http-equiv="Content-Type" content="text/html; charset=us-ascii" /> |
| |
| <meta http-equiv="Content-Style-Type" content="text/css" /> |
| <meta http-equiv="Content-Script-Type" content="text/javascript" /> |
| <title>Managing the persistence.xml file</title> |
| <meta name="generator" content="Oracle DARB XHTML Converter (Mode = ohj/ohw) - Version 5.1.1" /> |
| <meta name="date" content="2010-05-19T8:12:42Z" /> |
| <meta name="robots" content="noarchive" /> |
| <meta name="doctitle" content="Managing the persistence.xml file" /> |
| <meta name="relnum" content="Release 2.3" /> |
| <meta name="copyright" content="Copyright (c) 2000, 2008 oracle . All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at http://www.eclipse.org/legal/epl-v10.html. Contributors: Oracle - initial API and implementation" /> |
| <link rel="copyright" href="dcommon/html/cpyr.htm" title="Copyright" type="text/html" /> |
| <link rel="stylesheet" href="dcommon/css/blafdoc.css" title="Oracle BLAFDoc" type="text/css" /> |
| <!-- contents --> |
| </head> |
| <body> |
| <p><a id="CIHDAJID" name="CIHDAJID"></a></p> |
| <div class="sect1"><!-- infolevel="all" infotype="General" --> |
| <h1><a id="sthref47" name="sthref47"></a>Managing the persistence.xml file</h1> |
| <p><a id="sthref48" name="sthref48"></a>When you create a project, Eclipse creates the <code>META-INF\persistence.xml</code> file in the project's directory.</p> |
| <p>You can create a stub <code>persistence.xml</code> file in the META-INF directory when you create a JPA project (see <a href="task_create_new_project.htm#CIHHEJCJ">"Creating a new JPA project"</a>). You can manage this file either through the XML editor (see ) or through the <a href="ref_persistence_xmll_editor.htm#CIACCHID">persistence.xml Editor</a>.</p> |
| <div align="center"> |
| <div class="inftblnote"><br /> |
| <table class="Note oac_no_warn" summary="" cellpadding="3" cellspacing="0"> |
| <tbody> |
| <tr> |
| <td align="left"> |
| <p class="notep1">Note:</p> |
| Depending on your JPA implementation (for example, EclipseLink), the following additional pages may be available in the persistence.xml Editor: |
| <ul> |
| <li> |
| <p><a href="reference019.htm#CIAJAFEG">Customization</a></p> |
| <p>Use this page to define change-tracking and session customizer-related properties.</p> |
| </li> |
| <li> |
| <p><a href="reference020.htm#CIABEDCH">Caching</a></p> |
| <p>Use this page to define caching properties.</p> |
| </li> |
| <li> |
| <p><a href="reference021.htm#CIABGHHI">Logging</a></p> |
| <p>Use this page to define logging properties.</p> |
| </li> |
| <li> |
| <p><a href="reference022.htm#CIAFJCHE">Options</a></p> |
| <p>Use this page to define session and target database properties.</p> |
| </li> |
| <li> |
| <p><a href="reference023.htm#CIACCFCB">Schema Generation</a></p> |
| <p>Use this page to define DDL-related properties.</p> |
| </li> |
| </ul> |
| <p>For projects using the EclipseLink JPA implementation, the Connections page also includes JDBC connection pool properties.</p> |
| <p>If the project uses the Generic platform, then only the <a href="ref_persistence_general.htm#CIACIFGJ">General</a>, <a href="reference018.htm#CIAFFJIE">Connection</a>, <a href="reference024.htm#CIAHJDFF">Properties</a> and <a href="reference025.htm#CIAHCJAH">Source</a> pages are available.</p> |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| <br /></div> |
| <!-- class="inftblnote" --></div> |
| <p>To use the <code>persistence.xml</code> Editor:</p> |
| <ol> |
| <li> |
| <p>Open the <code>peristence.xml</code> file. The <a href="ref_persistence_general.htm#CIACIFGJ">General</a> page of the editor appears.</p> |
| </li> |
| <li> |
| <p>Use the <span class="bold">General</span> page to define the <code>persistence.xml</code> files <code><persistent-unit></code>-related attributes as well as the <code><provider></code>, and <code><class></code> elements (described in the following table).</p> |
| <div align="center"> |
| <div class="inftblnotealso"><br /> |
| <table class="NoteAlso oac_no_warn" summary="" cellpadding="3" cellspacing="0"> |
| <tbody> |
| <tr> |
| <td align="left"> |
| <p class="notep1">Tip:</p> |
| The persistence.xml Editor's Source page enables you to view and edit the raw XML file.</td> |
| </tr> |
| </tbody> |
| </table> |
| <br /></div> |
| <!-- class="inftblnotealso" --></div> |
| <div class="inftblinformal"> |
| <table class="Informal" summary="This table lists the properties of the persistence.xml editor." dir="ltr" border="1" width="100%" frame="hsides" rules="groups" cellpadding="3" cellspacing="0"> |
| <col width="29%" /> |
| <col width="29%" /> |
| <col width="*" /> |
| <thead> |
| <tr align="left" valign="top"> |
| <th align="left" valign="bottom" id="r1c1-t8">Property</th> |
| <th align="left" valign="bottom" id="r1c2-t8">Description</th> |
| <th align="left" valign="bottom" id="r1c3-t8">Element Defined</th> |
| </tr> |
| </thead> |
| <tbody> |
| <tr align="left" valign="top"> |
| <td align="left" id="r2c1-t8" headers="r1c1-t8">Name</td> |
| <td align="left" headers="r2c1-t8 r1c2-t8">Enter the name of the persistence unit.</td> |
| <td align="left" headers="r2c1-t8 r1c3-t8"><code><persistence-unit name = "<Name>"></code></td> |
| </tr> |
| <tr align="left" valign="top"> |
| <td align="left" id="r3c1-t8" headers="r1c1-t8"><a id="sthref49" name="sthref49"></a>Persistence Provider</td> |
| <td align="left" headers="r3c1-t8 r1c2-t8">Enter the name of the persistence provider.</td> |
| <td align="left" headers="r3c1-t8 r1c3-t8"><code><provider></code></td> |
| </tr> |
| <tr align="left" valign="top"> |
| <td align="left" id="r4c1-t8" headers="r1c1-t8">Description</td> |
| <td align="left" headers="r4c1-t8 r1c2-t8">Enter a description for this persistence unit. This is an optional property.</td> |
| <td align="left" headers="r4c1-t8 r1c3-t8"><code><description></code></td> |
| </tr> |
| <tr align="left" valign="top"> |
| <td align="left" id="r5c1-t8" headers="r1c1-t8"><a id="sthref50" name="sthref50"></a>Managed Classes</td> |
| <td align="left" headers="r5c1-t8 r1c2-t8">Add or remove the classes managed through the persistence unit.</td> |
| <td align="left" headers="r5c1-t8 r1c3-t8"><code><class></code></td> |
| </tr> |
| <tr align="left" valign="top"> |
| <td align="left" id="r6c1-t8" headers="r1c1-t8"> Exclude Unlisted Classes</td> |
| <td align="left" headers="r6c1-t8 r1c2-t8">Select to include all annotated entity classes in the root of the persistence unit.</td> |
| <td align="left" headers="r6c1-t8 r1c3-t8"><code><exclude-unlisted-classes></code></td> |
| </tr> |
| <tr align="left" valign="top"> |
| <td align="left" id="r7c1-t8" headers="r1c1-t8">XML Mapping Files</td> |
| <td align="left" headers="r7c1-t8 r1c2-t8">Add or remove the object/relational mapping XML files define the classes managed through the persistence unit.</td> |
| <td align="left" headers="r7c1-t8 r1c3-t8"><code><mapping-file></code></td> |
| </tr> |
| <tr align="left" valign="top"> |
| <td align="left" id="r8c1-t8" headers="r1c1-t8">JAR Files</td> |
| <td align="left" headers="r8c1-t8 r1c2-t8">Add or remove additional JAR files and libraries</td> |
| <td align="left" headers="r8c1-t8 r1c3-t8"><br /></td> |
| </tr> |
| </tbody> |
| </table> |
| <br /></div> |
| <!-- class="inftblinformal" --></li> |
| <li> |
| <p>Use the <a href="reference018.htm#CIAFFJIE">Connection</a> page to define the <code><jta-data-source></code> and <code><non-jta-data-source></code> elements as follows:</p> |
| <p>To configure the JTA (Java Transaction API) source used by the persistence provider:</p> |
| <ol> |
| <li> |
| <p>Select <span class="bold">JTA</span> from the Transaction Type list.</p> |
| </li> |
| <li> |
| <p>Enter the global JNDI name of the data source.</p> |
| </li> |
| </ol> |
| <p>To configure a non-JTA data source:</p> |
| <ol> |
| <li> |
| <p>Select <span class="bold">Resource Local</span> from the Transaction Type list.</p> |
| </li> |
| <li> |
| <p>Enter the global JNDI name of the data source.</p> |
| <div align="center"> |
| <div class="inftblnote"><br /> |
| <table class="Note oac_no_warn" summary="" cellpadding="3" cellspacing="0"> |
| <tbody> |
| <tr> |
| <td align="left"> |
| <p class="notep1">Note:</p> |
| Select <span class="bold">Default()</span> to use the data source provided by the container.</td> |
| </tr> |
| </tbody> |
| </table> |
| <br /></div> |
| <!-- class="inftblnote" --></div> |
| </li> |
| </ol> |
| <p><a id="sthref51" name="sthref51"></a>For projects using the Generic platform, you can also define the EclipseLink connection pool driver, connection pool driver, URL, user name and password.</p> |
| </li> |
| <li> |
| <p>Use the table in the Properties page to set the vendor-specific <code><properties></code> element.</p> |
| <p>To add <code><property></code> elements:</p> |
| <ol> |
| <li> |
| <p>Click <span class="bold">Add</span>.</p> |
| </li> |
| <li> |
| <p>Enter the <code><name></code> and <code><value></code> attributes for the <code><property></code> element using the table's Name and Value fields.</p> |
| </li> |
| </ol> |
| <p>To remove a <code><property></code> element, select a defined property in the table and then click <span class="bold">Remove</span>.</p> |
| <div align="center"> |
| <div class="inftblnote"><br /> |
| <table class="Note oac_no_warn" summary="" cellpadding="3" cellspacing="0"> |
| <tbody> |
| <tr> |
| <td align="left"> |
| <p class="notep1">Note:</p> |
| If the project uses the EclipseLink platform, the connection page also includes parameters for JDBC connection pooling.</td> |
| </tr> |
| </tbody> |
| </table> |
| <br /></div> |
| <!-- class="inftblnote" --></div> |
| </li> |
| </ol> |
| <img src="img/ngrelr.png" alt="Related reference" title="Related reference" /><br /> |
| <br /> |
| <a href="ref_persistence_xmll_editor.htm#CIACCHID">persistence.xml Editor</a> |
| <p> </p> |
| <img src="img/ngrelt.png" alt="Related task" title="Related task" /><br /> |
| <br /> |
| <a href="tasks002.htm#CIHFEBAI">Synchronizing classes</a><br /> |
| <p> </p> |
| <img src="img/ngrelc.png" alt="Related concept" title="Related concept" /><br /> |
| <br /> |
| <a href="concepts002.htm#CHDHAGIH">The persistence.xml file</a><br /> |
| <!-- Start Footer --> |
| <div class="footer"> |
| <table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%"> |
| <col width="86%" /> |
| <col width="*" /> |
| <tr> |
| <td align="left"><span class="copyrightlogo">Copyright © 2006, 2010, Oracle and/or its affiliates. All rights reserved.</span><br /> |
| <a href="dcommon/html/cpyr.htm"><span class="copyrightlogo">Legal Notices</span></a></td> |
| </tr> |
| </table> |
| </div> |
| <!-- class="footer" --></div> |
| </body> |
| </html> |