Skip to main content
summaryrefslogblamecommitdiffstats
blob: f88a6d747232324aaa392d3d738e0d56f050ed7e (plain) (tree)
1
2
3
4
5
6
7
8
9
10



                                                                   
                                         
                                                                        

                                     

                                                                   
                                                                                              
                                                        
                                          


                                                                                                                                                                                                                                                                                                                                                                      

                                                                                               

                 

       


                                                              
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              

                                                                                                                       
              
    
                                                 

     
                                               

     






                                                                                                                         
                                                         


                                                                                                                                                             
     

                      



                                                                                          
                                                                                                                                                                                                





                       
<!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 = July 23, 2008 8:59:45 -->
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
<title>Creating Named Queries</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="Creating Named Queries" />
<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" />
<!-- start-->
<!-- contents -->
</head>
<body>
<p><a id="BABIGBGG" name="BABIGBGG"></a></p>
<div class="sect1"><!-- infolevel="all" infotype="General" -->
<h1>Creating Named Queries</h1>
<p><a id="sthref94" name="sthref94"></a><a id="sthref95" name="sthref95"></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 start="1">
<li>
<p>Select the entity in the Package Explorer.</p>
</li>
<li>
<p>In the JPA Details view, expand Queries.</p>
</li>
<li>
<p>Click <span class="bold">Add</span> for a named query, or <span class="bold">Add Native</span> for a native query.</p>
</li>
<li>
<p>In the dialog that appears, enter the name of the query in the Name field and then click OK.</p>
</li>
<li>
<p>Enter the query in the Query field.</p>
<div class="figure"><a id="sthref96" name="sthref96"></a>
<p class="titleinfigure">Entering a Named Query</p>
<img src="img/task_entering_query.png" alt="The Queries section of the JPA Details view." title="The Queries section of the JPA Details view." /><br /></div>
<!-- class="figure" --></li>
</ol>
</div>
<!-- class="sect1" -->
<!-- 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" -->
</body>
</html>

Back to the top