Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 47e2327202914807fb594e8c6c2bcde865786cb6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
<!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="2012-09-11T7:44:4Z" />
<meta name="robots" content="noarchive" />
<meta name="doctitle" content="Managing the persistence.xml file" />
<meta name="relnum" content="Release 3.2" />
<meta name="partnum" content="Release 3.2" />
<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 class="betadraftsubtitle">Beta Draft: 2012-09-11</p>
<p><a id="CIHDAJID" name="CIHDAJID"></a></p>
<div class="sect1"><!-- infolevel="all" infotype="General" -->
<h1><a id="sthref93" name="sthref93"></a>Managing the persistence.xml file</h1>
<p><a id="sthref94" name="sthref94"></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="sthref95" name="sthref95"></a>
<p class="titleinexample">Sample persistence.xml File</p>
<pre xml:space="preserve" class="oac_no_warn">
&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;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"&gt;
     &lt;persistence-unit name="QuickStart"&gt;
          &lt;class&gt;quickstart.demo.model.Address&lt;/class&gt;
          &lt;class&gt;quickstart.demo.model.Item&lt;/class&gt;
     &lt;/persistence-unit&gt;
&lt;/persistence&gt;
</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="sthref96" name="sthref96"></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> &ndash;</p>
</li>
<li>
<p><a href="reference046.htm#CIAFFJIE">Connection</a> &ndash;</p>
</li>
<li>
<p><a href="reference047.htm#CIAJAFEG">Customization</a> &ndash; Use this page to define change-tracking and session customizer-related properties.</p>
</li>
<li>
<p><a href="reference048.htm#CIABEDCH">Caching</a> &ndash; Use this page to define caching properties.</p>
</li>
<li>
<p><a href="reference049.htm#CIABGHHI">Logging</a> &ndash; Use this page to define logging properties.</p>
</li>
<li>
<p><a href="reference050.htm#CIAFJCHE">Options</a> &ndash; Use this page to define session and target database properties.</p>
</li>
<li>
<p><a href="reference051.htm#CIACCFCB">Schema Generation</a> &ndash; Use this page to define DDL-related properties.</p>
</li>
<li>
<p><a href="reference052.htm#CIAHJDFF">Properties</a> &ndash;</p>
</li>
<li>
<p><a href="reference053.htm#CIAHCJAH">Source</a> &ndash;</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="reference046.htm#CIAFFJIE">Connection</a>, <a href="reference052.htm#CIAHJDFF">Properties</a> and <a href="reference053.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>&lt;persistent-unit&gt;</code>-related attributes as well as the <code>&lt;provider&gt;</code>, and <code>&lt;class&gt;</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="sthref97" name="sthref97"></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="reference046.htm#CIAFFJIE">Connection</a> page to define the <code>&lt;jta-data-source&gt;</code> and <code>&lt;non-jta-data-source&gt;</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="sthref98" name="sthref98"></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="sthref99" name="sthref99"></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="reference046.htm#CIAFFJIE">Connection</a> page.</p>
</li>
<li>
<p>Use the table in the Properties page to set the vendor-specific <code>&lt;properties&gt;</code> element.</p>
<p>To add <code>&lt;property&gt;</code> elements:</p>
<ol>
<li>
<p>Click <span class="bold">Add</span>.</p>
</li>
<li>
<p>Enter the <code>&lt;name&gt;</code> and <code>&lt;value&gt;</code> attributes for the <code>&lt;property&gt;</code> element using the table's Name and Value fields.</p>
</li>
</ol>
<p>To remove a <code>&lt;property&gt;</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="sthref100" name="sthref100"></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="reference047.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>
<a id="sthref101" name="sthref101"></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="sthref102" name="sthref102"></a>
<p class="subhead2">Related tasks</p>
<ul>
<li>
<p><a href="tasks006.htm#CIHFEBAI">Synchronizing classes</a></p>
</li>
</ul>
<a id="sthref103" name="sthref103"></a>
<p class="subhead2">Related concepts</p>
<ul>
<li>
<p><a href="concepts002.htm#CHDHAGIH">The persistence.xml file</a></p>
</li>
</ul>
<!-- 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&nbsp;&copy;&nbsp;2011, 2012,&nbsp;Oracle&nbsp;and/or&nbsp;its&nbsp;affiliates.&nbsp;All&nbsp;rights&nbsp;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>

Back to the top