| <!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="copyright" content="Copyright (c) 2000, 2009 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" /> |
| <meta name="generator" content="Oracle DARB XHTML Converter (Mode = ohj/ohw) - Version 1.0.11" /> |
| <meta name="date" content="2013-04-05T12:21:28Z" /> |
| <meta name="robots" content="noarchive" /> |
| <meta name="doctitle" content="Managing the persistence.xml file" /> |
| <meta name="relnum" content="Release 3.3" /> |
| <meta name="partnum" content="Release 3.3" /> |
| <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" /> |
| </head> |
| <body> |
| <p><a id="CIHDAJID" name="CIHDAJID"></a></p> |
| <div class="sect1"><!-- infolevel="all" infotype="General" --> |
| <h1><a id="ABC4949575" name="ABC4949575"></a><a id="ABC4949575SRI1" name="ABC4949575SRI1"></a>Managing the persistence.xml file</h1> |
| <p><a id="sthref127" name="sthref127"></a>When you create a project, Eclipse creates the <code>META-INF\persistence.xml</code> file in the project's directory.</p> |
| <div class="example"><a id="sthref128" name="sthref128"></a> |
| <p class="titleinexample">Sample persistence.xml File</p> |
| <pre xml:space="preserve" class="oac_no_warn"> |
| <?xml version="1.0" encoding="UTF-8"?> |
| <persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"> |
| <persistence-unit name="QuickStart"> |
| <class>quickstart.demo.model.Address</class> |
| <class>quickstart.demo.model.Item</class> |
| </persistence-unit> |
| </persistence> |
| </pre></div> |
| <!-- class="example" --> |
| <p>You can manage this file either through the XML editor or through the <a href="ref_persistence_xmll_editor.htm#CIACCHID">persistence.xml Editor</a>.</p> |
| <div class="figure"><a id="sthref129" name="sthref129"></a> |
| <p class="titleinfigure">The persistence.xml Editor</p> |
| <img src="img/persistence_editor_general.png" alt="General tab of persistence.xml editor" title="General tab of persistence.xml editor" /><br /></div> |
| <!-- class="figure" --> |
| <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> |
| <p>Depending on your JPA implementation (for example, EclipseLink), the following pages may be available in the persistence.xml Editor:</p> |
| <ul> |
| <li> |
| <p><a href="ref_persistence_general.htm#CIACIFGJ">General</a> – Use this page to define the classes, mapping files, and JAR files for the persistence unit.</p> |
| </li> |
| <li> |
| <p><a href="reference054.htm#CIAFFJIE">Connection</a> – Use this page to define the datasource (JTA and non-JTA elements) for the project.</p> |
| </li> |
| <li> |
| <p><a href="reference055.htm#CIAJAFEG">Customization</a> – Use this page to define change-tracking and session customizer-related properties.</p> |
| </li> |
| <li> |
| <p><a href="reference056.htm#CIABEDCH">Caching</a> – Use this page to define caching properties.</p> |
| </li> |
| <li> |
| <p><a href="reference057.htm#CIABGHHI">Logging</a> – Use this page to define logging properties.</p> |
| </li> |
| <li> |
| <p><a href="reference058.htm#CIAFJCHE">Options</a> – Use this page to define session and target database properties.</p> |
| </li> |
| <li> |
| <p><a href="reference059.htm#CIACCFCB">Schema Generation</a> – Use this page to define DDL-related properties.</p> |
| </li> |
| <li> |
| <p><a href="reference060.htm#CIAHJDFF">Properties</a> – Use to add or remove vender-specific properties.</p> |
| </li> |
| <li> |
| <p><a href="reference061.htm#CIAHCJAH">Source</a> – Use to view or modify the XML source of the <code>persistence.xml</code> file.</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="reference054.htm#CIAFFJIE">Connection</a>, <a href="reference060.htm#CIAHJDFF">Properties</a> and <a href="reference061.htm#CIAHCJAH">Source</a> pages are available.</p> |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| <br /></div> |
| <!-- class="inftblnote" --></div> |
| <p>To use the persistence.xml 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> |
| <p>The persistence.xml Editor's Source page enables you to view and edit the raw XML file.</p> |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| <br /></div> |
| <!-- class="inftblnotealso" --></div> |
| <div class="figure"><a id="sthref130" name="sthref130"></a> |
| <p class="titleinfigure">General tab of persistence.xml Editor</p> |
| <img src="img/persistence_editor_general.png" alt="General tab of persistence.xml editor" title="General tab of persistence.xml editor" /><br /></div> |
| <!-- class="figure" --></li> |
| <li> |
| <p>Complete each field on the <a href="ref_persistence_general.htm#CIACIFGJ">General</a> page.</p> |
| </li> |
| <li> |
| <p>Use the <a href="reference054.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> |
| <p>Select <span class="bold">Default()</span> to use the data source provided by the container.</p> |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| <br /></div> |
| <!-- class="inftblnote" --></div> |
| </li> |
| </ol> |
| <p><a id="sthref131" name="sthref131"></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> |
| <div class="figure"><a id="sthref132" name="sthref132"></a> |
| <p class="titleinfigure">Connection tab of persistence.xml Editor</p> |
| <img src="img/persistence_editor_connection.png" alt="Connection tab of persistence.xml Editor" title="Connection tab of persistence.xml Editor" /><br /></div> |
| <!-- class="figure" --></li> |
| <li> |
| <p>Complete each field on the <a href="reference054.htm#CIAFFJIE">Connection</a> page.</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> |
| <p>If the project uses the EclipseLink platform, the connection page also includes parameters for JDBC connection pooling.</p> |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| <br /></div> |
| <!-- class="inftblnote" --></div> |
| <div class="figure"><a id="sthref133" name="sthref133"></a> |
| <p class="titleinfigure">Customization tab of persistence.xml Editor</p> |
| <img src="img/persistence_editor_customization.png" alt="Customization tab of persistence.xml Editor" title="Customization tab of persistence.xml Editor" /><br /></div> |
| <!-- class="figure" --></li> |
| <li> |
| <p>Complete each field on the <a href="reference055.htm#CIAJAFEG">Customization</a> page.</p> |
| </li> |
| </ol> |
| <p>Additional pages may be available for the persistence.xml editor, depending on your JPA provider. See <a href="ref_persistence_xmll_editor.htm#CIACCHID">"persistence.xml Editor"</a> for more information.</p> |
| <ul> |
| <li> |
| <p><a href="reference056.htm#CIABEDCH">Caching</a> page</p> |
| <div class="figure"><a id="sthref134" name="sthref134"></a> |
| <p class="titleinfigure">Caching tab of persistence.xml Editor</p> |
| <img src="img/persistence_editor_caching.png" alt="persistence.xml Editor - Caching tab" title="persistence.xml Editor - Caching tab" /><br /></div> |
| <!-- class="figure" --></li> |
| <li> |
| <p><a href="reference057.htm#CIABGHHI">Logging</a> page</p> |
| <div class="figure"><a id="sthref135" name="sthref135"></a> |
| <p class="titleinfigure">Logging tab of persistence.xml Editor</p> |
| <img src="img/persistence_editor_logging.png" alt="persistence.xml Editor - Logging tab" title="persistence.xml Editor - Logging tab" /><br /></div> |
| <!-- class="figure" --></li> |
| <li> |
| <p><a href="reference058.htm#CIAFJCHE">Options</a> page</p> |
| <div class="figure"><a id="sthref136" name="sthref136"></a> |
| <p class="titleinfigure">Options tab of persistence.xml Editor</p> |
| <img src="img/persistence_editor_options.png" alt="persistence.xml Editor - Options tab" title="persistence.xml Editor - Options tab" /><br /></div> |
| <!-- class="figure" --></li> |
| <li> |
| <p><a href="reference059.htm#CIACCFCB">Schema Generation</a> page</p> |
| <div class="figure"><a id="sthref137" name="sthref137"></a> |
| <p class="titleinfigure">Schema Generation tab of persistence.xml Editor</p> |
| <img src="img/persistence_editor_schemageneration.png" alt="persistence.xml Editor - Schema Generation tab" title="persistence.xml Editor - Schema Generation tab" /><br /></div> |
| <!-- class="figure" --></li> |
| <li> |
| <p><a href="reference060.htm#CIAHJDFF">Properties</a> page</p> |
| <div class="figure"><a id="sthref138" name="sthref138"></a> |
| <p class="titleinfigure">Properties tab of persistence.xml Editor</p> |
| <img src="img/persistence_editor_properties.png" alt="persistence.xml Editor - Properties tab" title="persistence.xml Editor - Properties tab" /><br /></div> |
| <!-- class="figure" --></li> |
| <li> |
| <p><a id="sthref139" name="sthref139"></a><a id="sthref140" name="sthref140"></a><a href="reference061.htm#CIAHCJAH">Source</a> page</p> |
| <div class="figure"><a id="sthref141" name="sthref141"></a> |
| <p class="titleinfigure">Source tab of persistence.xml Editor</p> |
| <img src="img/persistence_editor_source.png" alt="persistence.xml Editor - Source tab" title="persistence.xml Editor - Source tab" /><br /></div> |
| <!-- class="figure" --></li> |
| </ul> |
| <a id="sthref142" name="sthref142"></a> |
| <p class="subhead2">Related reference</p> |
| <ul> |
| <li> |
| <p><a href="ref_persistence_xmll_editor.htm#CIACCHID">persistence.xml Editor</a></p> |
| </li> |
| </ul> |
| <a id="sthref143" name="sthref143"></a> |
| <p class="subhead2">Related tasks</p> |
| <ul> |
| <li> |
| <p><a href="task_manage_persistence001.htm#CIHHEFAI">Synchronizing classes</a></p> |
| </li> |
| </ul> |
| <a id="sthref144" name="sthref144"></a> |
| <p class="subhead2">Related concepts</p> |
| <ul> |
| <li> |
| <p><a href="concepts002.htm#CHDHAGIH">The persistence.xml file</a></p> |
| </li> |
| </ul> |
| </div> |
| <!-- class="sect1" --> |
| <!-- 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 © 2011, 2013, 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" --> |
| </body> |
| </html> |