blob: 29d8979de79f39d2130c7550ca50c05012346ad5 [file] [log] [blame]
<!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>About JPQL Queries | EclipseLink 2.5.x Understanding EclipseLink</title>
<meta name="generator" content="Oracle DARB XHTML Converter (Mode = document) - Version 1.0.17" />
<meta name="date" content="2013-10-03T10:37:16Z" />
<meta name="robots" content="noarchive" />
<meta name="doctitle" content="About JPQL Queries" />
<meta name="relnum" content="2.5" />
<link rel="stylesheet" type="text/css" href="../../dcommon/style.css" media="screen" />
<link rel="copyright" href="../../dcommon/html/cpyr.htm" title="Copyright" type="text/html" />
<link rel="start" href="../../index.htm" title="Home" type="text/html" />
<link rel="contents" href="toc.htm" title="Contents" type="text/html" />
<link rel="prev" href="queries001.htm" title="Previous" type="text/html" />
<link rel="next" href="queries003.htm" title="Next" type="text/html" />
<!-- START: Disqus --><script type="text/javascript"> var disqus_developer = 0; </script><!-- END: Disqus --><!-- START: Sharethis --><script type="text/javascript">var switchTo5x=true;</script><script type="text/javascript" src="http://w.sharethis.com/button/buttons.js"></script><script type="text/javascript" src="http://s.sharethis.com/loader.js"></script> <!-- END: Sharethis --></head>
<body bgcolor="#FFFFFF"><iframe id="docheader" frameborder="0" framemargin="0" scrolling="no" src="../../dcommon/header.html"></iframe><script src="http://www.google.com/jsapi" type="text/javascript"></script><script type="text/javascript"> google.load('search', '1', {language : 'en'}); google.setOnLoadCallback(function() { var customSearchOptions = {}; var googleAnalyticsOptions = {}; googleAnalyticsOptions['queryParameter'] = 'q'; googleAnalyticsOptions['categoryParameter'] = ''; customSearchOptions['googleAnalyticsOptions'] = googleAnalyticsOptions; var customSearchControl = new google.search.CustomSearchControl( '016171230611334810008:mdbgdwjv8zu', customSearchOptions); customSearchControl.setResultSetSize(google.search.Search.FILTERED_CSE_RESULTSET); var options = new google.search.DrawOptions(); options.setSearchFormRoot('cse-search-form'); customSearchControl.draw('cse', options); }, true);</script><link rel="stylesheet" href="http://www.google.com/cse/style/look/default.css" type="text/css" /><div id="cse" style="width:100%;"></div>
<div class="header"><a id="top" name="top"></a>
<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%">
<tr>
<td align="left" valign="top"><div class="booktitle">Understanding EclipseLink,
<b>2.5</b><br /></font></td>
<td valign="bottom" align="right" width="144">
<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%">
<tr>
<td>&nbsp;</td>
<td align="center" valign="top"><a href="toc.htm"><img src="../../dcommon/images/contents.png" alt="Go To Table Of Contents" border="0" height="16" width="16" /><br />
</td><td>&nbsp;</td><td align="center"><a href="../../" target="_top" class="external text" title="Search" rel="nofollow"><img src="../../dcommon/images/search.png" alt="Search" style="border:0;" /><br /><span class="mini"></span></a></td><td>&nbsp;</td><td align="center"><a href="../eclipselink_otlcg.pdf" title="PDF" target="_blank"><img src="../../dcommon/images/pdf_icon.png" style="padding-right:5px;border:0" alt="PDF"></a></td>
</tr>
</table>
</td>
</tr>
</table>
<hr />
<table class="navigation simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100" align="center">
<tr>
<td align="center"><a href="queries001.htm"><img src="../../dcommon/images/larrow.png" alt="Previous" border="0" height="16" width="16" /></a></td>
<td align="center"><a href="queries003.htm"><img src="../../dcommon/images/rarrow.png" alt="Next" border="0" height="16" width="16" /></a></td>
<td>&nbsp;</td>
</tr>
</table>
</div>
<!-- class="header" -->
<div class="ind"><!-- End Header --><a id="CHDJHGFI" name="CHDJHGFI"></a><a id="OTLCG94000" name="OTLCG94000"></a>
<div class="sect1">
<h1 class="sect1"><font face="arial, helvetica, sans-serif" color="#330099">About JPQL Queries</font></h1>
<p>The Java Persistence Query Language (JPQL) is the query language defined by JPA. JPQL is similar to SQL, but operates on objects, attributes and relationships instead of tables and columns. JPQL can be used for reading (<code>SELECT</code>), as well as bulk updates (<code>UPDATE</code>) and deletes (<code>DELETE</code>). JPQL can be used in a <code>NamedQuery</code> (through annotations or XML) or in dynamic queries using the <code>EntityManager</code> <code>createQuery()</code> API.</p>
<p>The disadvantage of JPQL is that dynamic queries require performing string concatenations to build queries dynamically from web forms or dynamic content. JPQL is also not checked until runtime, making typographical errors more common. These disadvantages are reduced by using the query criteria API, described in the next section.</p>
<p>For more information, see Chapter 4 "Query Language" in the JPA Specification.</p>
<p><code><a href="http://jcp.org/en/jsr/detail?id=317">http://jcp.org/en/jsr/detail?id=317</a></code></p>
<a id="OTLCG94354" name="OTLCG94354"></a>
<div class="sect2"><a id="sthref72" name="sthref72"></a>
<h2 class="sect2"><font face="arial, helvetica, sans-serif" color="#330099">Select Queries</font></h2>
<p>Select queries can be used to read objects from the database. Select queries can return a single object or data element, a list of objects or data elements, or an object array of multiple objects and data.</p>
<a id="OTLCG94355" name="OTLCG94355"></a>
<div class="sect3"><a id="sthref73" name="sthref73"></a>
<h3 class="sect3"><font face="arial, helvetica, sans-serif" color="#330099">SELECT Clause</font></h3>
<p>The <code>SELECT</code> clause can contain object expressions, attribute expressions, functions, sub-selects, constructors and aggregation functions.</p>
<a id="OTLCG94356" name="OTLCG94356"></a>
<div class="sect4"><a id="sthref74" name="sthref74"></a>
<h4 class="sect4"><font face="arial, helvetica, sans-serif" color="#330099">Aggregation functions</font></h4>
<p>Aggregation functions can include summary information on a set of objects. These include <code>MIN</code>, <code>MAX</code>, <code>AVG</code>, <code>SUM</code>, <code>COUNT</code>. These functions can be used to return a single result, or can be used with a <code>GROUP</code> <code>BY</code> to return multiple results.</p>
</div>
<!-- class="sect4" -->
<a id="OTLCG94357" name="OTLCG94357"></a>
<div class="sect4"><a id="sthref75" name="sthref75"></a>
<h4 class="sect4"><font face="arial, helvetica, sans-serif" color="#330099">Constructors</font></h4>
<p>The <code>NEW</code> operator can be used with the fully-qualified class name to return data objects from a JPQL query. These will not be managed objects, and the class must define a constructor that matches the arguments of the constructor and their types. Constructor queries can be used to select partial data or reporting data on objects, and get back a class instance instead of an object array.</p>
</div>
<!-- class="sect4" --></div>
<!-- class="sect3" -->
<a id="OTLCG94358" name="OTLCG94358"></a>
<div class="sect3"><a id="sthref76" name="sthref76"></a>
<h3 class="sect3"><font face="arial, helvetica, sans-serif" color="#330099">FROM Clause</font></h3>
<p>The <code>FROM</code> clause defines what is being queried. A typical <code>FROM</code> clause will contain the entity name being queried and assign it an alias.</p>
<p>JPQL allows for multiple root level objects to be queried. Caution should be used when doing this, as it can result in Cartesian products of the two tables. The <code>WHERE</code> or <code>ON</code> clause should ensure the two objects are joined in some way.</p>
<p>The entity name used in JPQL comes from the name attribute of the <code>@Entity</code> annotation or XML. It defaults to the simple entity class name. EclipseLink also allows for the fully-qualified class name of the entity to be used.</p>
<a id="OTLCG94359" name="OTLCG94359"></a>
<div class="sect4"><a id="sthref77" name="sthref77"></a>
<h4 class="sect4"><font face="arial, helvetica, sans-serif" color="#330099">JOIN</font></h4>
<p>A <code>JOIN</code> clause can also be used in the <code>FROM</code> clause. The <code>JOIN</code> clause allows any of the object's relationships to be joined into the query so they can be used in the <code>WHERE</code> clause. <code>JOIN</code> does not mean the relationships will be fetched, unless the <code>FETCH</code> option is included.</p>
<p><code>JOIN</code> can be used with OneToOne, ManyToOne, OneToMany, ManyToMany and ElementColleciton mappings. When used with a collection relationship you can join the same relationship multiple times to query multiple independent values.</p>
</div>
<!-- class="sect4" -->
<a id="OTLCG94360" name="OTLCG94360"></a>
<div class="sect4"><a id="sthref78" name="sthref78"></a>
<h4 class="sect4"><font face="arial, helvetica, sans-serif" color="#330099">JOIN FETCH</font></h4>
<p>The <code>FETCH</code> option can be used on a <code>JOIN</code> to fetch the related objects in a single query. This avoids additional queries for each of the object's relationships, and ensures that the relationships have been fetched if they were <code>LAZY</code>. EclipseLink also supports batch fetching through query hints.</p>
<p><code>JOIN</code> <code>FETCH</code> normally allows an alias. The alias should be used with caution, as it can affect how the resulting objects are built. Objects should normally always have the same data, no matter how they were queried, this is important for caching and consistency. This is only an issue if the alias is used in the <code>WHERE</code> clause on a collection relationship to filter the related objects that will be fetched. This should not be done, but is sometimes desirable, in which case the query should ensure it has been set to BYPASS the cache.</p>
</div>
<!-- class="sect4" -->
<a id="OTLCG94361" name="OTLCG94361"></a>
<div class="sect4"><a id="sthref79" name="sthref79"></a>
<h4 class="sect4"><font face="arial, helvetica, sans-serif" color="#330099">LEFT JOIN</font></h4>
<p>By default all joins in JPQL are <code>INNER</code> joins. This means that results that do not have the relationship will be filtered from the query results. To avoid this, a join can be defined as an <code>OUTER</code> join using the <code>LEFT</code> options.</p>
</div>
<!-- class="sect4" -->
<a id="OTLCG94362" name="OTLCG94362"></a>
<div class="sect4"><a id="sthref80" name="sthref80"></a>
<h4 class="sect4"><font face="arial, helvetica, sans-serif" color="#330099">ON</font></h4>
<p>The <code>JOIN</code> condition used for a join comes from the mapping's join columns. This means that the JPQL user is normally free from having to know how every relationship is joined. In some cases it is desirable to append additional conditions to the join condition, normally in the case of outer joins. This can be done through the <code>ON</code> clause. EclipseLink also supports usage of the ON clause between two root level objects.</p>
<p>For <code>INNER</code> joins, EclipseLink will normally append the join condition to the <code>WHERE</code> clause, but this can be configured in the <code>DatabasePlatform</code>.</p>
</div>
<!-- class="sect4" -->
<a id="OTLCG94363" name="OTLCG94363"></a>
<div class="sect4"><a id="sthref81" name="sthref81"></a>
<h4 class="sect4"><font face="arial, helvetica, sans-serif" color="#330099">Sub-selects in FROM clause</font></h4>
<p>Sub-selects are supported in the <code>FROM</code> clause. This requires that the database supports this functionality.</p>
</div>
<!-- class="sect4" --></div>
<!-- class="sect3" -->
<a id="OTLCG94364" name="OTLCG94364"></a>
<div class="sect3"><a id="sthref82" name="sthref82"></a>
<h3 class="sect3"><font face="arial, helvetica, sans-serif" color="#330099">ORDER BY clause</font></h3>
<p><code>ORDER</code> <code>BY</code> allows the ordering of the results to be specified. Multiple values can be ordered, either ascending (<code>ASC</code>) or descending (<code>DESC</code>). EclipseLink allows functions, sub-selects and other operations in the <code>ORDER</code> <code>BY</code> clause. EclipseLink allows objects expressions to be used in the <code>ORDER</code> <code>BY</code>. In the case of entity objects, they are ordered by their Id, in case of embeddable objects, they are ordered by all of their fields. EclipseLink also allows for <code>NULL</code> ordering to be specified (either <code>FIRST</code> or <code>LAST</code>).</p>
</div>
<!-- class="sect3" -->
<a id="OTLCG94365" name="OTLCG94365"></a>
<div class="sect3"><a id="sthref83" name="sthref83"></a>
<h3 class="sect3"><font face="arial, helvetica, sans-serif" color="#330099">GROUP BY Clause</font></h3>
<p><code>GROUP</code> <code>BY</code> allows for summary information to be computed on a set of objects. <code>GROUP</code> <code>BY</code> is normally used in conjunction with aggregation functions. EclipseLink supports using objects, functions and sub-selects in the <code>GROUP</code> <code>BY</code> clause.</p>
</div>
<!-- class="sect3" -->
<a id="OTLCG94366" name="OTLCG94366"></a>
<div class="sect3"><a id="sthref84" name="sthref84"></a>
<h3 class="sect3"><font face="arial, helvetica, sans-serif" color="#330099">HAVING Clause</font></h3>
<p>The <code>HAVING</code> clause allows for the results of a <code>GROUP</code> <code>BY</code> to be filtered. EclipseLink supports using comparisons, objects, functions and sub-selects in the <code>HAVING</code> clause.</p>
</div>
<!-- class="sect3" -->
<a id="OTLCG94367" name="OTLCG94367"></a>
<div class="sect3"><a id="sthref85" name="sthref85"></a>
<h3 class="sect3"><font face="arial, helvetica, sans-serif" color="#330099">UNION</font></h3>
<p>EclipseLink supports <code>UNION</code>, <code>INTERSECT</code> and <code>EXCEPT</code> operations. <code>UNION</code> allows the results of two queries with equivalent result structures to be combined into a single query. The unique results from both queries will be returned. If the <code>ALL</code> option is used, then results found in both queries will be duplicated.</p>
<p><code>INTERSECT</code> returns only the results that are found in both queries. <code>EXCEPT</code> removes the results from the second query from the results from the first query.</p>
<p>The JPA spec does not support union operations.</p>
</div>
<!-- class="sect3" --></div>
<!-- class="sect2" -->
<a id="OTLCG94368" name="OTLCG94368"></a>
<div class="sect2"><a id="sthref86" name="sthref86"></a>
<h2 class="sect2"><font face="arial, helvetica, sans-serif" color="#330099">WHERE Clause</font></h2>
<p>The <code>WHERE</code> clause is normally the main part of the query as it defines the conditions that filter what is returned. The <code>WHERE</code> clause can use any comparison operation, logical operation, functions, attributes, objects, and sub-selects. The comparison operations include =, &lt;, &gt;, &lt;=, &gt;=, &lt;&gt;, <code>LIKE</code>, <code>BETWEEN</code>, <code>IS</code> <code>NULL</code>, and <code>IN</code>. <code>NOT</code> can also be used with any comparison operation (<code>NOT</code> <code>LIKE</code>, <code>NOT</code> <code>BETWEEN</code>, <code>IS</code> <code>NOT</code> <code>NULL</code>, <code>NOT</code> <code>IN</code>). The logical operations include <code>AND</code>, <code>OR</code>, and <code>NOT</code>.</p>
<p>EclipseLink also supports the <code>REGEXP</code> operation to perform regular expression comparisons (requires database to support regular expressions). EclipseLink allows for functions and sub-selects to be used with any operation.</p>
<p>The <code>IN</code> operation allows for a list of values or parameters, a single list parameter, or a sub-select.</p>
<p>A sub-select can be used with any operation provided it returns a single value, or if the <code>ALL</code> or <code>ANY</code> options are used. <code>ALL</code> indicates the operation must be true for all elements returned by the sub-select, <code>ANY</code> indicates the operation must be true for any of the elements returned by the sub-select.</p>
<p>EclipseLink allows the =, &lt;&gt;, <code>IS</code> <code>NULL</code>, <code>IS</code> <code>NOT</code> <code>NULL</code>, <code>IN</code> and <code>NOT</code> <code>IN</code> operations on objects. If <code>IN</code> is used on an object and the object has a composite Id, this requires the database to support nested <code>IN</code> lists.</p>
</div>
<!-- class="sect2" -->
<a id="OTLCG94369" name="OTLCG94369"></a>
<div class="sect2"><a id="sthref87" name="sthref87"></a>
<h2 class="sect2"><font face="arial, helvetica, sans-serif" color="#330099">Update Queries</font></h2>
<p>You can perform bulk update of entities with the <code>UPDATE</code> statement. This statement operates on a single entity type and sets one or more single-valued properties of the entity subject to the condition in the <code>WHERE</code> clause. Update queries provide an equivalent to the SQL <code>UPDATE</code> statement, but with JPQL conditional expressions.</p>
<p>Update queries do not allow joins, but do support sub-selects. OneToOne and ManyToOne relationships can be traversed in the <code>WHERE</code> clause. Collection relationships can still be queried through using an <code>EXISTS</code> in the <code>WHERE</code> clause with a sub-select. Update queries can only update attributes of the object or its embeddables, its relationships cannot be updated. Complex update queries are dependent on the database's update support, and may make use of temp tables on some databases.</p>
<p>Update queries should only be used for bulk updates, regular updates to objects should be made by using the object's set methods within a transaction and committing the changes.</p>
<p>Update queries return the number of modified rows on the database (row count).</p>
<p>The persistence context is not updated to reflect results of update operations. If you use a transaction-scoped persistence context, you should either execute the bulk operation in a transaction all by itself, or be the first operation in the transaction. That is because any entity actively managed by the persistence context will remain unaware of the actual changes occurring at the database level.</p>
<p>The objects in the shared cache that match the update query will be invalidated to ensure subsequent persistence contexts see the updated data.</p>
</div>
<!-- class="sect2" -->
<a id="OTLCG94370" name="OTLCG94370"></a>
<div class="sect2"><a id="sthref88" name="sthref88"></a>
<h2 class="sect2"><font face="arial, helvetica, sans-serif" color="#330099">Delete Queries</font></h2>
<p>You can perform bulk removal of entities with the <code>DELETE</code> statement. Delete queries provide an equivalent to the SQL <code>DELETE</code> statement, but with JPQL conditional expressions.</p>
<p>Delete queries do not allow joins, but do support sub-selects. OneToOne and ManyToOne relationships can be traversed in the <code>WHERE</code> clause. Collection relationships can still be queried through using an <code>EXISTS</code> in the <code>WHERE</code> clause with a sub-select. Complex delete queries are dependent on the database's delete support, and may make use of temp tables on some databases.</p>
<p>Delete queries should only be used for bulk deletes, regular deletes to objects should be performed through calling the EntityManager <code>remove()</code> API.</p>
<p>Delete queries return the number of deleted rows on the database (row count).</p>
<div align="center">
<div class="inftblnote"><br />
<table class="Note oac_no_warn" summary="" border="1" width="80%" frame="hsides" rules="groups" cellpadding="3" cellspacing="0">
<tbody>
<tr>
<td align="left">
<p class="note"><img src="../../dcommon/images/note_icon.png" width="16" height="16" alt="Note" style="vertical-align:middle;padding-right:5px;" />Note:</p>
<p>Delete queries are polymorphic: any entity subclass instances that meet the criteria of the delete query will be deleted. However, delete queries do not honor cascade rules: no entities other than the type referenced in the query and its subclasses will be removed, even if the entity has relationships to other entities with cascade removes enabled. Delete queries will delete the rows from join and collection tables.</p>
</td>
</tr>
</tbody>
</table>
<br /></div>
<!-- class="inftblnote" --></div>
<p>The persistence context is not updated to reflect results of delete operations. If you use a transaction-scoped persistence context, you should either execute the bulk operation in a transaction all by itself, or be the first operation in the transaction. That is because any entity actively managed by the persistence context will remain unaware of the actual changes occurring at the database level.</p>
<p>The objects in the shared cache that match the delete query will be invalidated to ensure subsequent persistence contexts do not see the removed objects.</p>
</div>
<!-- class="sect2" -->
<a id="OTLCG94371" name="OTLCG94371"></a>
<div class="sect2"><a id="sthref89" name="sthref89"></a>
<h2 class="sect2"><font face="arial, helvetica, sans-serif" color="#330099">Parameters</font></h2>
<p>JPA defines named parameters, and positional parameters. Named parameters can be specified in JPQL using the syntax <code>:&lt;name&gt;</code>. Positional parameters can be specified in JPQL using the syntax <code>?</code> or <code>?&lt;position&gt;</code>. Positional parameters start at position <code>1</code> not <code>0</code>.</p>
<a id="OTLCG94372" name="OTLCG94372"></a>
<div class="sect3"><a id="sthref90" name="sthref90"></a>
<h3 class="sect3"><font face="arial, helvetica, sans-serif" color="#330099">Literals</font></h3>
<p>Literal values can be in-lined in JPQL for standard Java types. In general it is normally better to use parameters instead of in-lining values. In-lined arguments will prevent the JPQL from benefiting from the JPQL parser cache, and can potentially make the application vulnerable to JPQL injections attacks.</p>
<p>Each Java type defines its own in-lining syntax:</p>
<ul>
<li>
<p>String - '&lt;string&gt;'</p>
<p>To define a ' (quote) character in a string, the quote is double quoted, i.e. 'Baie-D''Urf&eacute;'.</p>
</li>
<li>
<p>Integer - +|-&lt;digits&gt;</p>
</li>
<li>
<p>Long - +|-&lt;digits&gt;L</p>
</li>
<li>
<p>Float - +|-&lt;digits&gt;.&lt;decimal&gt;&lt;exponent&gt;F</p>
</li>
<li>
<p>Double - +|-&lt;digits&gt;.&lt;decimal&gt;&lt;exponent&gt;D</p>
</li>
<li>
<p>Boolean - TRUE | FALSE</p>
</li>
<li>
<p>Date - {d'yyyy-mm-dd'}</p>
</li>
<li>
<p>Time - {t'hh:mm:ss'}</p>
</li>
<li>
<p>Timestamp - {ts'yyyy-mm-dd hh:mm:ss.nnnnnnnnn'} -</p>
</li>
<li>
<p>Enum - package.class.enum</p>
</li>
<li>
<p>null - NULL</p>
</li>
</ul>
</div>
<!-- class="sect3" --></div>
<!-- class="sect2" -->
<a id="OTLCG94373" name="OTLCG94373"></a>
<div class="sect2"><!-- infolevel="all" infotype="General" --><a id="sthref91" name="sthref91"></a>
<h2 class="sect2"><font face="arial, helvetica, sans-serif" color="#330099">Functions</font></h2>
<p>JPQL supports several database functions. These functions are database independent in name and syntax, but require database support. If the database supports an equivalent function, then the standard JPQL function is supported. If the database does not provide any way to perform the function, then it is not supported. For mathematical functions (+, -, /, *) BEDMAS rules apply.</p>
<p>In JPQL, support functions can be used in the <code>SELECT</code>, <code>WHERE</code>, <code>ORDER</code> <code>BY</code>, <code>GROUP</code> <code>BY</code> and <code>HAVING</code> clauses, as well as inside other functions, with comparison operators, and in constructors.</p>
<p>EclipseLink provides support for several functions beyond the JPA spec. EclipseLink also supports calling specific database functions through <code>FUNCTION</code>, <code>FUNC</code>, and <code>OPERATOR</code>.</p>
</div>
<!-- class="sect2" -->
<a id="OTLCG94374" name="OTLCG94374"></a>
<div class="sect2"><!-- infolevel="all" infotype="General" --><a id="sthref92" name="sthref92"></a>
<h2 class="sect2"><font face="arial, helvetica, sans-serif" color="#330099">EclipseLink Special Operators</font></h2>
<p>EclipseLink defines several special JPQL operators that allow performing database operations that are not possible in basic JPQL. These include:</p>
<ul>
<li>
<p><code>FUNCTION</code></p>
</li>
<li>
<p><code>OPERATOR</code></p>
</li>
<li>
<p><code>SQL</code></p>
</li>
<li>
<p><code>COLUMN</code></p>
</li>
</ul>
<p>For descriptions of these operators, see "Special Operators" in <em>Java Persistence API (JPA) Extensions Reference for EclipseLink</em>.</p>
</div>
<!-- class="sect2" -->
<a id="OTLCG94375" name="OTLCG94375"></a>
<div class="sect2"><!-- infolevel="all" infotype="General" --><a id="sthref93" name="sthref93"></a>
<h2 class="sect2"><font face="arial, helvetica, sans-serif" color="#330099">EclipseLink Extensions</font></h2>
<p>EclipseLink provides many extensions to the standard JPA JPQL. These extensions provide access to additional database features many of which are part of the SQL standard, provide access to native database features and functions, and provide access to EclipseLink specific features.</p>
<p>EclipseLink's JPQL extensions include:</p>
<ul>
<li>
<p>Less restrictions than JPQL, allows sub-selects and functions within operations such as <code>LIKE</code>, <code>IN</code>, <code>ORDER</code> <code>BY</code>, constructors, functions etc.</p>
</li>
<li>
<p>Allow != in place of &lt;&gt;</p>
</li>
<li>
<p><code>FUNCTION</code> operation to call database specific functions</p>
</li>
<li>
<p><code>TREAT</code> operation to downcast related entities with inheritance</p>
</li>
<li>
<p><code>OPERATOR</code> operation to call EclipseLink database independent functions</p>
</li>
<li>
<p><code>SQL</code> operation to mix <code>SQL</code> with JPQL</p>
</li>
<li>
<p><code>CAST</code> and <code>EXTRACT</code> functions</p>
</li>
<li>
<p><code>REGEXP</code> function for regular expression querying</p>
</li>
<li>
<p>Usage of sub-selects in the <code>SELECT</code> and <code>FROM</code> clause</p>
</li>
<li>
<p><code>ON</code> clause support for defining <code>JOIN</code> and <code>LEFT</code> <code>JOIN</code> conditions</p>
</li>
<li>
<p>Joins between independent entities</p>
</li>
<li>
<p>Usage of an alias on a <code>JOIN</code> <code>FETCH</code></p>
</li>
<li>
<p><code>COLUMN</code> operation to allow querying on non mapped columns</p>
</li>
<li>
<p><code>TABLE</code> operation to allow querying on non mapped tables</p>
</li>
<li>
<p><code>UNION</code>, <code>INTERSECT</code>, <code>EXCEPT</code> support</p>
</li>
<li>
<p>Usage of object variables in =, &lt;&gt;, <code>IN</code>, <code>IS</code> <code>NULL</code>, and <code>ORDER</code> <code>BY</code></p>
</li>
</ul>
<p>For descriptions of these extensions, see "EclipseLink Query Language" in <em>Java Persistence API (JPA) Extensions Reference for EclipseLink</em>.</p>
</div>
<!-- class="sect2" --></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="navigation simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100" align="center">
<col width="*" />
<col width="48%" />
<col width="48%" />
<tr>
<td>&nbsp;</td>
<td align="center"><a href="queries001.htm"><img src="../../dcommon/images/larrow.png" alt="Previous" border="0" height="16" width="16" /></a></td>
<td align="center"><a href="queries003.htm"><img src="../../dcommon/images/rarrow.png" alt="Next" border="0" height="16" width="16" /></a></td>
</tr>
</table>
</td>
<td align="center" width="34%"><a href="http://www.eclipse.org/eclipselink/" title="EclipseLink home"><img src="../../dcommon/images/ellogo.png" alt="EclipseLink" width="150" border="0" /></a><br />
<td valign="bottom" align="right">
<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="225">
<tr>
<td>&nbsp;</td>
<td align="center" valign="top"><a href="toc.htm"><img src="../../dcommon/images/contents.png" alt="Go To Table Of Contents" border="0" height="16" width="16" /><br />
</td><td>&nbsp;</td><td align="center"><a href="../../" target="_top" class="external text" title="Search" rel="nofollow"><img src="../../dcommon/images/search.png" alt="Search" style="border:0;" /><br /><span class="mini"></span></a></td><td>&nbsp;</td><td align="center"><a href="../eclipselink_otlcg.pdf" title="PDF" target="_blank"><img src="../../dcommon/images/pdf_icon.png" style="padding-right:5px;border:0" alt="PDF"></a></td>
</tr>
</table>
</td>
</tr>
</table>
</div>
<!-- class="footer" -->
<div id="copyright">Copyright &copy; 2012 by The Eclipse Foundation under the <a href="http://www.eclipse.org/org/documents/epl-v10.php">Eclipse Public License (EPL)</a><br /> <script type="text/javascript">var LastUpdated = document.lastModified;document.writeln ("Updated: " + LastUpdated);</script> </div><!-- START: Analytics --><script type="text/javascript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-1608008-2']); _gaq.push(['_trackPageview']); (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })(); </script><!-- END: Analytics --><!-- START: Sharethis --><script>var options={ "publisher": "e2fe9e07-fab6-4f84-83ea-0991b429842c", "position": "right", "ad": { "visible": false, "openDelay": 5, "closeDelay": 0}};var st_hover_widget = new sharethis.widgets.hoverbuttons(options);</script><!-- END: Sharethis --></body>
</html>