Skip to main content

Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "EclipseLink/UserGuide/JPA/A additionalcriteria"

m
m
Line 1: Line 1:
<div class="header">
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 
+
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
{| class="simple oac_no_warn" width="100%"
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
| align="left" valign="top" | <font face="helvetica, arial, sans-serif">'''EclipseLink JPA Extensions Reference Guide'''<br />'''Version 2.4.x'''<br /></font>
+
<head>
| width="144" align="right" valign="bottom" |
+
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
{| class="simple oac_no_warn" width="100%"
+
<meta http-equiv="Content-Style-Type" content="text/css" />
|
+
<meta http-equiv="Content-Script-Type" content="text/javascript" />
| align="center" valign="top" |
+
<title>@AdditionalCriteria</title>
[[toc.htm|<font size="-2">Contents</font>]]
+
|}
+
|}
+
 
+
----
+
 
+
{| class="simple oac_no_warn" width="100"
+
| align="center" |
+
[[a_additionalcriteria.htm|Previous]]
+
| align="center" |
+
[[a_array.htm|Next]]
+
|
+
|}
+
 
+
</div><div class="ind">
+
----
+
<div class="refsect1">
+
 
+
= <font color="#330099" face="arial, helvetica, sans-serif">@AdditionalCriteria</font> =
+
 
+
Use <code>@AdditionalCriteria</code> to define parameterized views on data. You can define additional criteria on entities or mapped superclasses. When specified at the mapped superclass level, the additional criteria definition applies to all inheriting entities, unless those entities define their own additional criteria, in which case those defined for the mapped superclass are ignored.
+
 
+
'''<font color="#330099" face="arial, helvetica, sans-serif">Annotation Elements</font>'''
+
 
+
[#CHDGJGDCxx Table 2-1] describes this annotation's elements.
+
 
+
<div class="tblhruleformalwide">
+
 
+
'''''<font face="arial, helvetica, sans-serif">Table 2-1 @AdditionalCriteria Annotation Elements</font>'''''
+
 
+
{| class="HRuleFormalWide" dir="ltr" title="@AdditionalCriteria Annotation Elements" summary="This table describes the list of attributes for this annotation." width="100%" border="1" frame="hsides" rules="rows" cellpadding="3" frame="hsides" rules="rows"
+
|- align="left" valign="top"
+
! id="r1c1-t2" align="left" valign="bottom" | <font face="Arial, Helvetica, sans-serif">'''Attribute'''</font>
+
! id="r1c2-t2" align="left" valign="bottom" | <font face="Arial, Helvetica, sans-serif">'''Description'''</font>
+
! id="r1c3-t2" align="left" valign="bottom" | <font face="Arial, Helvetica, sans-serif">'''Default'''</font>
+
|- align="left" valign="top"
+
| id="r2c1-t2" headers="r1c1-t2" align="left" |
+
<code>value</code>
+
| headers="r2c1-t2 r1c2-t2" align="left" |
+
(Required) The JPQL fragment to use as the additional criteria.
+
| headers="r2c1-t2 r1c3-t2" align="left" | <br />
+
|}
+
 
+
<br /></div>
+
 
+
'''<font color="#330099" face="arial, helvetica, sans-serif">Usage</font>'''
+
 
+
Set additional criteria parameters through properties on the entity manager factory or on the entity manager. Properties set on the entity manager override identically named properties set on the entity manager factory. Properties must be set on an entity manager before executing a query. Do not change the properties for the lifespan of the entity manager.
+
 
+
Additional criteria are not supported with native queries.
+
 
+
Specify additional criteria using the <code>@AdditionalCriteria</code> annotation or the <code>&lt;additional-criteria&gt;</code> element. The additional criteria definition supports any valid JPQL string and must use <code>this</code> as an alias to form the additional criteria. For example:
+
 
+
 
   
 
   
@AdditionalCriteria("this.address.city IS NOT NULL")
+
<meta name="date" content="2012-05-17T9:17:7Z" />
 
+
<meta name="robots" content="noarchive" />
The following example shows additional criteria defined for the entity <code>Employee</code> and then shows the parameters for the additional criteria set on the entity manager.
+
<meta name="doctitle" content="@AdditionalCriteria" />
 
+
Define additional criteria on <code>Employee</code>, as follows:
+
 
+
 
   
 
   
package model;
 
 
   
 
   
@AdditionalCriteria("this.company=:COMPANY")
 
public class Employee {
 
  ...
 
}
 
 
then set the property on the <code>EntityManager</code>. This example returns all employees of MyCompany.
 
 
 
   
 
   
&lt;additional-criteria&gt;  &lt;criteria&gt;this.address.city IS NOT NULL&lt;/criteria&gt;&lt;/additional-criteria&gt;
 
 
'''<font color="#330099" face="arial, helvetica, sans-serif">Uses for Additional Criteria</font>'''
 
 
Uses for additional criteria include:
 
 
Multitenancy Example
 
 
In a multitenancy environment, tenants (users, clients, organizations, applications) can share database tables, but the views on the data are restricted so that tenants have access only to their own data. You can use additional criteria to configure such restrictions.
 
 
Multitenancy Example 1
 
 
The following example restricts the data for a “Billing” client, such as a billing application or billing organization:
 
 
 
   
 
   
@AdditionalCriteria("this.tenant = 'Billing'")
+
<link rel="contents" href="toc.htm" title="Contents" type="text/html" />
 
+
<link rel="prev" href="a_additionalcriteria.htm" title="Previous" type="text/html" />
Multitenancy Example 2
+
<link rel="next" href="a_array.htm" title="Next" type="text/html" />
 
+
</head>
The following example could be used in an application used by multiple tenants at the same time. The additional criteria is defined as:
+
<body bgcolor="#FFFFFF">
 
+
<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"><font face="helvetica, arial, sans-serif"><b>EclipseLink JPA Extensions Reference Guide</b><br />
 +
<b>Version 2.4.x</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">
 +
<font size="-2">Contents</font></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="a_additionalcriteria.htm">Previous</a></td>
 +
<td align="center"><a href="a_array.htm">Next</a></td>
 +
<td>&nbsp;</td>
 +
</tr>
 +
</table>
 +
</div>
 +
<!-- class="header" -->
 +
<div class="ind"><!-- End Header --><a id="BABCJADG" name="BABCJADG"></a>
 +
<hr />
 +
<div class="refsect1">
 +
<h1 class="refsect1"><font face="arial, helvetica, sans-serif" color="#330099">@AdditionalCriteria</font></h1>
 +
<p>Use <code>@AdditionalCriteria</code> to define parameterized views on data. You can define additional criteria on entities or mapped superclasses. When specified at the mapped superclass level, the additional criteria definition applies to all inheriting entities, unless those entities define their own additional criteria, in which case those defined for the mapped superclass are ignored.</p>
 +
<a id="sthref11" name="sthref11"></a>
 +
<p><strong><font face="arial, helvetica, sans-serif" color="#330099">Annotation Elements</font></strong></p>
 +
<p><a href="#CHDGJGDCxx">Table 2-1</a> describes this annotation's elements.</p>
 +
<div class="tblhruleformalwide"><a id="sthref12" name="sthref12"></a><a id="CHDGJGDCxx" name="CHDGJGDCxx"></a>
 +
<p><strong><em><font face="arial, helvetica, sans-serif">Table 2-1 @AdditionalCriteria Annotation Elements</font></em></strong></p>
 +
<table class="HRuleFormalWide" title="@AdditionalCriteria Annotation Elements" summary="This table describes the list of attributes for this annotation." dir="ltr" border="1" width="100%" frame="hsides" rules="rows" cellpadding="3" cellspacing="0">
 +
<col width="27%" />
 +
<col width="*" />
 +
<col width="18%" />
 +
<thead>
 +
<tr align="left" valign="top">
 +
<th align="left" valign="bottom" id="r1c1-t2"><font face="Arial, Helvetica, sans-serif"><strong>Attribute</strong></font></th>
 +
<th align="left" valign="bottom" id="r1c2-t2"><font face="Arial, Helvetica, sans-serif"><strong>Description</strong></font></th>
 +
<th align="left" valign="bottom" id="r1c3-t2"><font face="Arial, Helvetica, sans-serif"><strong>Default</strong></font></th>
 +
</tr>
 +
</thead>
 +
<tbody>
 +
<tr align="left" valign="top">
 +
<td align="left" id="r2c1-t2" headers="r1c1-t2">
 +
<p><code>value</code></p>
 +
</td>
 +
<td align="left" headers="r2c1-t2 r1c2-t2">
 +
<p>(Required) The JPQL fragment to use as the additional criteria.</p>
 +
</td>
 +
<td align="left" headers="r2c1-t2 r1c3-t2"><br /></td>
 +
</tr>
 +
</tbody>
 +
</table>
 +
<br /></div>
 +
<!-- class="tblhruleformalwide" -->
 +
<a id="sthref13" name="sthref13"></a>
 +
<p><strong><font face="arial, helvetica, sans-serif" color="#330099">Usage</font></strong></p>
 +
<p>Set additional criteria parameters through properties on the entity manager factory or on the entity manager. Properties set on the entity manager override identically named properties set on the entity manager factory. Properties must be set on an entity manager before executing a query. Do not change the properties for the lifespan of the entity manager.</p>
 +
<p>Additional criteria are not supported with native queries.</p>
 +
<p>Specify additional criteria using the <code>@AdditionalCriteria</code> annotation or the <code>&lt;additional-criteria&gt;</code> element. The additional criteria definition supports any valid JPQL string and must use <code>this</code> as an alias to form the additional criteria. For example:</p>
 +
<pre xml:space="preserve" class="oac_no_warn">
 +
@AdditionalCriteria("this.address.city IS NOT NULL")
 +
</pre>
 +
<p>The following example shows additional criteria defined for the entity <code>Employee</code> and then shows the parameters for the additional criteria set on the entity manager.</p>
 +
<p>Define additional criteria on <code>Employee</code>, as follows:</p>
 +
<pre xml:space="preserve" class="oac_no_warn">
 +
package model;
 
   
 
   
  @AdditionalCriteria("this.tenant = :tenant")
+
@AdditionalCriteria("this.company=:COMPANY")
 
+
public class Employee {
When the tenant acquires its <code>EntityManagerFactory</code> or <code>EntityManager</code>, the persistence/entity manager property tenant is set to the name of the tenant acquiring it. For example,
+
  ...
 
+
}
+
</pre>
Map properties = new HashMap();
+
<p>then set the property on the <code>EntityManager</code>. This example returns all employees of MyCompany.</p>
properties.put("tenant", "ACME");
+
<pre xml:space="preserve" class="oac_no_warn">
EntityManagerFactory emf = Persistence.createEntityManagerFactory(properties);
+
&lt;additional-criteria&gt; &lt;criteria&gt;this.address.city IS NOT NULL&lt;/criteria&gt;&lt;/additional-criteria&gt;
 
+
</pre>
Or
+
<a id="sthref14" name="sthref14"></a>
 
+
<p><b><font face="arial, helvetica, sans-serif" color="#330099">Uses for Additional Criteria</font></b></p>
+
<p>Uses for additional criteria include:</p>
Map properties = new HashMap();
+
<p>Multitenancy Example</p>
properties.put("tenant", "ACME");
+
<p>In a multitenancy environment, tenants (users, clients, organizations, applications) can share database tables, but the views on the data are restricted so that tenants have access only to their own data. You can use additional criteria to configure such restrictions.</p>
EntityManager em = factory.createEntityManager(properties);
+
<p>Multitenancy Example 1</p>
 
+
<p>The following example restricts the data for a &ldquo;Billing&rdquo; client, such as a billing application or billing organization:</p>
Soft Delete Example
+
<pre xml:space="preserve" class="oac_no_warn">
 
+
@AdditionalCriteria("this.tenant = 'Billing'")
The following example filters data that is marked as deleted (but which still exists in the table) from a query:
+
</pre>
 
+
<p>Multitenancy Example 2</p>
+
<p>The following example could be used in an application used by multiple tenants at the same time. The additional criteria is defined as:</p>
@AdditionalCriteria("this.isDeleted = false")
+
<pre xml:space="preserve" class="oac_no_warn">
 
+
@AdditionalCriteria("this.tenant = :tenant")
Data History Example
+
</pre>
 
+
<p>When the tenant acquires its <code>EntityManagerFactory</code> or <code>EntityManager</code>, the persistence/entity manager property tenant is set to the name of the tenant acquiring it. For example,</p>
The following example returns the current data from a query, thus filtering out any out-of-date data, for example data stored in a history table.
+
<pre xml:space="preserve" class="oac_no_warn">
 
+
Map properties = new HashMap();
+
properties.put("tenant", "ACME");
@AdditionalCriteria("this.endDate is null")
+
EntityManagerFactory emf = Persistence.createEntityManagerFactory(properties);
 
+
</pre>
<div><center><div class="inftblnote"><br />
+
<p>Or</p>
 
+
<pre xml:space="preserve" class="oac_no_warn">
{| class="Note oac_no_warn" width="80%" border="1" frame="hsides" rules="groups" cellpadding="3" frame="hsides" rules="groups"
+
Map properties = new HashMap();
| align="left" |
+
properties.put("tenant", "ACME");
<font face="arial, helvetica, sans-serif">'''Note:'''</font>
+
EntityManager em = factory.createEntityManager(properties);
 
+
</pre>
TopLink also provides specific history support, via <code>HistoryPolicy</code> . See Tracking Changes Using History Policy at <code>http://wiki.eclipse.org/EclipseLink/Examples/JPA/History</code>.
+
<p>Soft Delete Example</p>
|}
+
<p>The following example filters data that is marked as deleted (but which still exists in the table) from a query:</p>
 
+
<pre xml:space="preserve" class="oac_no_warn">
<br /></div></center></div>
+
@AdditionalCriteria("this.isDeleted = false")
 
+
</pre>
Temporal Filtering Example
+
<p>Data History Example</p>
 
+
<p>The following example returns the current data from a query, thus filtering out any out-of-date data, for example data stored in a history table.</p>
The following example filters on a specific date::
+
<pre xml:space="preserve" class="oac_no_warn">
 
+
@AdditionalCriteria("this.endDate is null")
+
</pre>
@AdditionalCriteria("this.startDate &lt;= :viewDate and this.endDate &gt;= :viewDate")
+
<div align="center">
 
+
<div class="inftblnote"><br />
Shared Table Example
+
<table class="Note oac_no_warn" summary="" border="1" width="80%" frame="hsides" rules="groups" cellpadding="3" cellspacing="0">
 
+
<tbody>
For a shared table, there may be inheritance in the table but not in the object model. For example, a SavingsAccount class may be mapped to an <code>ACCOUNT</code> table, but the <code>ACCOUNT</code> table contains both savings account data (<code>SAVINGS</code>) and checking account (<code>CHECKING</code>) data. You can use additional criteria to filter out the checking account data.
+
<tr>
 
+
<td align="left">
'''<font color="#330099" face="arial, helvetica, sans-serif">Examples</font>'''
+
<p><font face="arial, helvetica, sans-serif"><strong>Note:</strong></font></p>
 
+
TopLink also provides specific history support, via <code>HistoryPolicy</code> . See Tracking Changes Using History Policy at <code><a href="http://wiki.eclipse.org/EclipseLink/Examples/JPA/History">http://wiki.eclipse.org/EclipseLink/Examples/JPA/History</a></code>.</td>
 +
</tr>
 +
</tbody>
 +
</table>
 +
<br /></div>
 +
<!-- class="inftblnote" --></div>
 +
<p>Temporal Filtering Example</p>
 +
<p>The following example filters on a specific date::</p>
 +
<pre xml:space="preserve" class="oac_no_warn">
 +
@AdditionalCriteria("this.startDate &lt;= :viewDate and this.endDate &gt;= :viewDate")
 +
</pre>
 +
<p>Shared Table Example</p>
 +
<p>For a shared table, there may be inheritance in the table but not in the object model. For example, a SavingsAccount class may be mapped to an <code>ACCOUNT</code> table, but the <code>ACCOUNT</code> table contains both savings account data (<code>SAVINGS</code>) and checking account (<code>CHECKING</code>) data. You can use additional criteria to filter out the checking account data.</p>
 +
<a id="sthref15" name="sthref15"></a>
 +
<p><strong><font face="arial, helvetica, sans-serif" color="#330099">Examples</font></strong></p>
 +
<pre xml:space="preserve" class="oac_no_warn">
 +
Code
 +
</pre>
 +
<p>Alternatively, you can include a few examples using <code>SegmentedList</code> <code>Role = Example</code>.</p>
 +
<a id="sthref16" name="sthref16"></a>
 +
<p><strong><font face="arial, helvetica, sans-serif" color="#330099">See Also</font></strong></p>
 +
</div>
 +
<!-- class="refsect1" --></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>&nbsp;</td>
 +
<td align="center"><a href="a_additionalcriteria.htm">Previous</a></td>
 +
<td align="center"><a href="a_array.htm"><img src="../../dcommon/gifs/rarrow.gif" alt="Next" border="0" height="30" width="30" /></a></td>
 +
</tr>
 +
</table>
 +
</td>
 +
<td align="center" width="34%"><img src="http://wiki.eclipse.org/images/thumb/6/6b/Eclipselink-logo.gif/150px-Eclipselink-logo.gif" alt="EclispeLink" border="0" /> <br />
 
   
 
   
  Code
+
  </td>
 
+
<td valign="bottom" align="right">
Alternatively, you can include a few examples using <code>SegmentedList</code> <code>Role = Example</code>.
+
<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="225">
 
+
<tr>
'''<font color="#330099" face="arial, helvetica, sans-serif">See Also</font>'''
+
<td>&nbsp;</td>
 
+
<td align="center" valign="top"><a href="toc.htm">  
</div></div><div class="footer">
+
<font size="-2">Contents</font></a></td>
----
+
</tr>
 
+
</table>
{| class="simple oac_no_warn" width="100%"
+
</td>
|-
+
</tr>
| valign="bottom" |
+
</table>
{| class="simple oac_no_warn" width="100"
+
|-
+
|
+
| align="center" |
+
[a_additionalcriteria.htm [[Image:larrow.gif|Previous]]]
+
| align="center" |
+
[a_array.htm [[Image:rarrow.gif|Next]]]
+
|}
+
| width="34%" align="center" |
+
[[Image:150px-Eclipselink-logo.gif|EclispeLink]]<br />
+
| align="right" valign="bottom" |
+
{| class="simple oac_no_warn" width="225"
+
|
+
| align="center" valign="top" |
+
[toc.htm [[Image:conticon.gif|Go To Table Of Contents]]<br /><font size="-2">Contents</font>]
+
|}
+
|}
+
 
+
 
</div>
 
</div>
 +
<!-- class="footer" -->
 +
</body>
 +
</html>

Revision as of 09:18, 17 May 2012

<!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>@AdditionalCriteria</title>

<meta name="date" content="2012-05-17T9:17:7Z" /> <meta name="robots" content="noarchive" /> <meta name="doctitle" content="@AdditionalCriteria" />



<link rel="contents" href="toc.htm" title="Contents" type="text/html" /> <link rel="prev" href="a_additionalcriteria.htm" title="Previous" type="text/html" /> <link rel="next" href="a_array.htm" title="Next" type="text/html" /> </head> <body bgcolor="#FFFFFF">

<a id="top" name="top"></a>
EclipseLink JPA Extensions Reference Guide

Version 2.4.x

  <a href="toc.htm"> Contents</a>

<a href="a_additionalcriteria.htm">Previous</a> <a href="a_array.htm">Next</a>  
<a id="BABCJADG" name="BABCJADG"></a>

@AdditionalCriteria

Use @AdditionalCriteria to define parameterized views on data. You can define additional criteria on entities or mapped superclasses. When specified at the mapped superclass level, the additional criteria definition applies to all inheriting entities, unless those entities define their own additional criteria, in which case those defined for the mapped superclass are ignored.

<a id="sthref11" name="sthref11"></a>

Annotation Elements

<a href="#CHDGJGDCxx">Table 2-1</a> describes this annotation's elements.

<a id="sthref12" name="sthref12"></a><a id="CHDGJGDCxx" name="CHDGJGDCxx"></a>

Table 2-1 @AdditionalCriteria Annotation Elements

<col width="27%" /> <col width="*" /> <col width="18%" /> <thead> </thead> <tbody> </tbody>
Attribute Description Default

value

(Required) The JPQL fragment to use as the additional criteria.



<a id="sthref13" name="sthref13"></a>

Usage

Set additional criteria parameters through properties on the entity manager factory or on the entity manager. Properties set on the entity manager override identically named properties set on the entity manager factory. Properties must be set on an entity manager before executing a query. Do not change the properties for the lifespan of the entity manager.

Additional criteria are not supported with native queries.

Specify additional criteria using the @AdditionalCriteria annotation or the <additional-criteria> element. The additional criteria definition supports any valid JPQL string and must use this as an alias to form the additional criteria. For example:

@AdditionalCriteria("this.address.city IS NOT NULL")

The following example shows additional criteria defined for the entity Employee and then shows the parameters for the additional criteria set on the entity manager.

Define additional criteria on Employee, as follows:

package model;
 
@AdditionalCriteria("this.company=:COMPANY")
public class Employee {
  ...
}

then set the property on the EntityManager. This example returns all employees of MyCompany.

<additional-criteria>  <criteria>this.address.city IS NOT NULL</criteria></additional-criteria>

<a id="sthref14" name="sthref14"></a>

Uses for Additional Criteria

Uses for additional criteria include:

Multitenancy Example

In a multitenancy environment, tenants (users, clients, organizations, applications) can share database tables, but the views on the data are restricted so that tenants have access only to their own data. You can use additional criteria to configure such restrictions.

Multitenancy Example 1

The following example restricts the data for a “Billing” client, such as a billing application or billing organization:

@AdditionalCriteria("this.tenant = 'Billing'")

Multitenancy Example 2

The following example could be used in an application used by multiple tenants at the same time. The additional criteria is defined as:

@AdditionalCriteria("this.tenant = :tenant")

When the tenant acquires its EntityManagerFactory or EntityManager, the persistence/entity manager property tenant is set to the name of the tenant acquiring it. For example,

Map properties = new HashMap();
properties.put("tenant", "ACME");
EntityManagerFactory emf = Persistence.createEntityManagerFactory(properties);

Or

Map properties = new HashMap();
properties.put("tenant", "ACME");
EntityManager em = factory.createEntityManager(properties);

Soft Delete Example

The following example filters data that is marked as deleted (but which still exists in the table) from a query:

@AdditionalCriteria("this.isDeleted = false")

Data History Example

The following example returns the current data from a query, thus filtering out any out-of-date data, for example data stored in a history table.

@AdditionalCriteria("this.endDate is null")

<tbody> </tbody>

Note:

TopLink also provides specific history support, via HistoryPolicy . See Tracking Changes Using History Policy at <a href="http://wiki.eclipse.org/EclipseLink/Examples/JPA/History">http://wiki.eclipse.org/EclipseLink/Examples/JPA/History</a>.

Temporal Filtering Example

The following example filters on a specific date::

@AdditionalCriteria("this.startDate <= :viewDate and this.endDate >= :viewDate")

Shared Table Example

For a shared table, there may be inheritance in the table but not in the object model. For example, a SavingsAccount class may be mapped to an ACCOUNT table, but the ACCOUNT table contains both savings account data (SAVINGS) and checking account (CHECKING) data. You can use additional criteria to filter out the checking account data.

<a id="sthref15" name="sthref15"></a>

Examples

Code

Alternatively, you can include a few examples using SegmentedList Role = Example.

<a id="sthref16" name="sthref16"></a>

See Also

</body> </html>

Back to the top