Skip to main content
summaryrefslogtreecommitdiffstats
blob: f8de8bf36a060cfad84cf96248ef4c695840f6be (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
<!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>Creating queries</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:31Z" />
<meta name="robots" content="noarchive" />
<meta name="doctitle" content="Creating queries" />
<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="BABIGBGG" name="BABIGBGG"></a></p>
<div class="sect1"><!-- infolevel="all" infotype="General" -->
<h1>Creating queries</h1>
<p><a id="sthref188" name="sthref188"></a><a id="sthref189" name="sthref189"></a>Named queries improve application performance because they are prepared once and they (and all of their associated supporting objects) can be efficiently reused thereafter, making them well suited for complex and frequently executed operations. Named queries use the JPA query language for portable execution on any underlying database; named native queries use the SQL language native to the underlying database.</p>
<p>Use this procedure to add <code>@NamedQuery</code> and <code>@NamedNativeQuery</code> annotations to the entity.</p>
<p>To create a named query:</p>
<ol>
<li>
<p>Select the entity in the Project Explorer.</p>
</li>
<li>
<p>In the JPA Details view, expand the <a href="reference025.htm#CACBICGJ">Queries</a> area.</p>
<div class="figure"><a id="sthref190" name="sthref190"></a>
<p class="titleinfigure">JPA Details, Queries Tab</p>
<img src="img/jpa_details_query_1.png" alt="" title="" /><br /></div>
<!-- class="figure" --></li>
<li>
<p>Click <span class="bold">Add</span> to add a new query. The <a href="reference076.htm#CACJIFEG">Add Query dialog</a> appears</p>
<div class="figure"><a id="sthref191" name="sthref191"></a>
<p class="titleinfigure">Add Query Dialog</p>
<img src="img/add_query.png" alt="Add Query dialog" title="Add Query dialog" /><br /></div>
<!-- class="figure" --></li>
<li>
<p>Enter the name of the query, select the query type (<span class="bold">Named Query</span> or <span class="bold">Named Native Query</span>), and click <span class="bold">OK</span>. The <a href="reference025.htm#CACBICGJ">Queries</a> area expands to show additional fields.</p>
<div class="figure"><a id="sthref192" name="sthref192"></a>
<p class="titleinfigure">JPA Details, Queries Tab</p>
<img src="img/jpa_details_query_2.png" alt="" title="" /><br /></div>
<!-- class="figure" --></li>
<li>
<p>Enter the query in the <span class="bold">Query</span> field.</p>
</li>
<li>
<p>Complete the rest of the field on the <a href="reference025.htm#CACBICGJ">Queries</a> page.</p>
</li>
<li>
<p><a id="sthref193" name="sthref193"></a><a id="sthref194" name="sthref194"></a><a id="sthref195" name="sthref195"></a><a id="sthref196" name="sthref196"></a>To add a Query hint, click <span class="bold">Add</span>. Enter the <span class="bold">Name</span> and <span class="bold">Value</span> of the hint.</p>
</li>
</ol>
<a id="sthref197" name="sthref197"></a>
<p class="subhead2">Related reference</p>
<ul>
<li>
<p><a href="reference025.htm#CACBICGJ">Queries</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&nbsp;&copy;&nbsp;2011, 2013,&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" -->
</body>
</html>

Back to the top