Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 67a45baac58f0903313618101a06dc03d945dc89 (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
<!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>
<!-- Run date = May 21, 2008 14:42:03 -->
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
<title>Managing the persistence.xml file</title>
 
<meta http-equiv="Content-Style-Type" content="text/css" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<meta name="generator" content="Oracle DARB XHTML Converter (Mode = ohj/ohw) - Version 5.0" />
<meta name="date" content="2005-07-10T12:57:20+08:00" />
<meta name="robots" content="noarchive" />
<meta name="doctitle" content="Managing the persistence.xml file" />
<meta name="relnum" content="Release 2.0" />
<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" />
<link rel="start" href="../../index.htm" title="Home" type="text/html" />
<link rel="contents" href="toc.htm" title="Contents" type="text/html" />
</head>
<body>
<p><a id="CIHDAJID" name="CIHDAJID"></a></p>
<div class="sect1"><!-- infolevel="all" infotype="General" -->
<h1><a id="sthref33" name="sthref33"></a>Managing the persistence.xml file</h1>
<p><a id="sthref34" name="sthref34"></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 <a href="tasks002.htm#CIHEJAIE">"Using the XML Editor to edit the persistence.xml file"</a>) or through the <a href="reference018.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>
In additon to the General, Connection, Properties and Source pages, the persistence.xml Editor pages for projects that use the EclipseLink platform include the following:
<ul>
<li>
<p><a href="reference021.htm#CIAJAFEG">Customization</a></p>
<p>Use this page to define change-tracking and session customizer-related properties.</p>
</li>
<li>
<p><a href="reference022.htm#CIABEDCH">Caching</a></p>
<p>Use this page to define caching properties.</p>
</li>
<li>
<p><a href="reference023.htm#CIABGHHI">Logging</a></p>
<p>Use this page to define logging properties.</p>
</li>
<li>
<p><a href="reference024.htm#CIAFJCHE">Options</a></p>
<p>Use this page to define session and target database properties.</p>
</li>
<li>
<p><a href="reference025.htm#CIACCFCB">Schema Generation</a></p>
<p>Use this page to define DDL-related properties.</p>
</li>
</ul>
<p>For projects using the EclipseLink platform, the Connections page also includes JDBC connection pool properties.</p>
<p>If the project uses the Generic platform, then only the General, Connection, Properties and Source pages are available.</p>
</td>
</tr>
</tbody>
</table>
<br /></div>
<!-- class="inftblnote" --></div>
<p>To use the <code>persistence.xml</code> Editor:</p>
<ol start="1">
<li>
<p>Open the <code>peristence.xml</code> file. The <a href="reference019.htm#CIACIFGJ">General</a> page of the editor appears.</p>
</li>
<li>
<p>Use the General 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>
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">
<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>&lt;persistence-unit name = "&lt;Name&gt;"&gt;</code></td>
</tr>
<tr align="left" valign="top">
<td align="left" id="r3c1-t8" headers="r1c1-t8">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>&lt;provider&gt;</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>&lt;description&gt;</code></td>
</tr>
<tr align="left" valign="top">
<td align="left" id="r5c1-t8" headers="r1c1-t8">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>&lt;class&gt;</code></td>
</tr>
<tr align="left" valign="top">
<td align="left" id="r6c1-t8" headers="r1c1-t8">&nbsp;&nbsp;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>&lt;exclude-unlisted-classes&gt;</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>&lt;mapping-file&gt;</code></td>
</tr>
</tbody>
</table>
<br /></div>
<!-- class="inftblinformal" --></li>
<li>
<p>Use the <a href="reference020.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 start="1">
<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 start="1">
<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>
</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 start="1">
<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>
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="reference018.htm#CIACCHID">persistence.xml Editor</a>
<p>&nbsp;</p>
<img src="img/ngrelt.png" alt="Related task" title="Related task" /><br />
<br />
<a href="tasks002.htm#CIHEJAIE">Using the XML Editor to edit the persistence.xml file</a><br />
<p>&nbsp;</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%">
<tr>
<td align="left" width="86%"><a href="dcommon/html/cpyr.htm"><span class="copyrightlogo">Copyright&nbsp;&copy;&nbsp;2006, 2008,&nbsp;Oracle.&nbsp;All&nbsp;rights&nbsp;reserved.</span></a></td>
</tr>
</table>
</div>
<!-- class="footer" --></div>
</body>
</html>

Back to the top