<!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="generator" content="Oracle DARB XHTML Converter (Mode = document) - Version 1.0.11" /> | |
<meta name="date" content="2012-12-19T9:17:42Z" /> | |
<meta name="robots" content="noarchive" /> | |
<meta name="doctitle" content="Creating queries" /> | |
<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" /> | |
<link rel="contents" href="toc.htm" title="Contents" type="text/html" /> | |
<link rel="up" href="../../index.htm" title="Home" type="text/html" /> | |
<link rel="up" href="toc.htm" title="User Guide" type="text/html" /> | |
<link rel="up" href="tasks.htm" title="Tasks" type="text/html" /> | |
<link rel="up" href="tasks005.htm" title="Creating queries" type="text/html" /> | |
<link rel="index" href="index.htm" title="Index" type="text/html" /> | |
<link rel="prev" href="task_inheritance.htm" title="Specifying entity inheritance" type="text/html" /> | |
<link rel="next" href="task_mapping.htm" title="Mapping an entity " type="text/html" /> | |
</head> | |
<body> | |
<div class="header"><a id="top" name="top"></a> | |
<div class="zz-skip-header"><a href="#BEGIN">Skip Headers</a></div> | |
<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%"> | |
<tr> | |
<td align="left" valign="top"><b>Dali Java Persistence Tools User Guide</b><br /> | |
<b>Release 3.2</b><br /> | |
Release 3.2</td> | |
<td valign="bottom" align="right"> | |
<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="225"> | |
<tr> | |
<td> </td> | |
<td align="center" valign="top"><a href="../dali_user_guide.pdf"><img src="dcommon/gifs/pdf_icon.png" alt="PDF" height="24" /><br /><span class="icon">PDF</span></a></td><td align="center" valign="top"><a href="toc.htm"><img src="dcommon/gifs/toc.gif" alt="Go To Table Of Contents" /><br /> | |
<span class="icon">Contents</span></a></td> | |
<td align="center" valign="top"><a href="index.htm"><img src="dcommon/gifs/index.gif" alt="Go To Index" /><br /> | |
<span class="icon">Index</span></a></td> | |
</tr> | |
</table> | |
</td> | |
</tr> | |
</table> | |
<hr /> | |
<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100"> | |
<tr> | |
<td align="center"><a href="task_inheritance.htm"><img src="dcommon/gifs/leftnav.gif" alt="Previous" /><br /> | |
<span class="icon">Specifying entity inheritance</span></a> </td> | |
<td align="center"><a href="task_mapping.htm"><img src="dcommon/gifs/rightnav.gif" alt="Next" /><br /> | |
<span class="icon">Mapping an entity</span></a></td> | |
<td> </td> | |
</tr> | |
</table> | |
<p id="BREADCRUMBING"><a href="../../index.htm" title="Home">Home</a> > <a href="toc.htm" title="User Guide">User Guide</a> > <a href="tasks.htm" title="Tasks">Tasks</a> > Creating queries</p> | |
<a name="BEGIN" id="BEGIN"></a></div> | |
<!-- class="header" --> | |
<div class="ind"><!-- End Header --><a id="BABIGBGG" name="BABIGBGG"></a> | |
<div class="sect1"><!-- infolevel="all" infotype="General" --> | |
<h1 class="sect1">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="reference002.htm#CACBICGJ">Queries</a> area.</p> | |
<div class="figure"><a id="sthref190" name="sthref190"></a> | |
<p class="titleinfigure">Figure 3-45 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="reference004.htm#CACJIFEG">Add Query dialog</a> appears</p> | |
<div class="figure"><a id="sthref191" name="sthref191"></a> | |
<p class="titleinfigure">Figure 3-46 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="reference002.htm#CACBICGJ">Queries</a> area expands to show additional fields.</p> | |
<div class="figure"><a id="sthref192" name="sthref192"></a> | |
<p class="titleinfigure">Figure 3-47 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="reference002.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="reference002.htm#CACBICGJ">Queries</a></p> | |
</li> | |
</ul> | |
</div> | |
<!-- class="sect1" --></div> | |
<!-- class="ind" --> | |
<!-- Start Footer --> | |
<div class="footer"> | |
<hr /> | |
<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%"> | |
<col width="33%" /> | |
<col width="*" /> | |
<col width="33%" /> | |
<tr> | |
<td valign="bottom"> | |
<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100"> | |
<col width="*" /> | |
<col width="48%" /> | |
<col width="48%" /> | |
<tr> | |
<td> </td> | |
<td align="center"><a href="task_inheritance.htm"><img src="dcommon/gifs/leftnav.gif" alt="Previous" /><br /> | |
<span class="icon">Specifying entity inheritance</span></a> </td> | |
<td align="center"><a href="task_mapping.htm"><img src="dcommon/gifs/rightnav.gif" alt="Next" /><br /> | |
<span class="icon">Mapping an entity</span></a></td> | |
</tr> | |
</table> | |
</td> | |
<td class="copyrightlogo"><img class="copyrightlogo" src="http://www.eclipse.org/eclipse.org-common/themes/Nova/images/eclipse.png" alt="Eclipse Logo" width="150"/><br /> | |
<span class="copyrightlogo">Copyright © 2011, 2012, by The Eclipse Foundation under the Eclipse Public License (EPL).</span> <a href="legal.htm"><br /> | |
<span class="copyrightlogo">Legal Notices</span></a></td> | |
<td valign="bottom" align="right"> | |
<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="225"> | |
<tr> | |
<td> </td> | |
<td align="center" valign="top"><a href="../dali_user_guide.pdf"><img src="dcommon/gifs/pdf_icon.png" alt="PDF" height="24" /><br /><span class="icon">PDF</span></a></td><td align="center" valign="top"><a href="toc.htm"><img src="dcommon/gifs/toc.gif" alt="Go To Table Of Contents" /><br /> | |
<span class="icon">Contents</span></a></td> | |
<td align="center" valign="top"><a href="index.htm"><img src="dcommon/gifs/index.gif" alt="Go To Index" /><br /> | |
<span class="icon">Index</span></a></td> | |
</tr> | |
</table> | |
</td> | |
</tr> | |
</table> | |
</div> | |
<!-- class="footer" --> | |
</body> | |
</html> |