summaryrefslogtreecommitdiffstats
path: root/documentation/jpacontainer/jpacontainer-filtering.asciidoc
blob: 98d062b8d00ebbdd9e8063f929b431d74649cd48 (plain)
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
---
title: Filtering JPAContainer
order: 6
layout: page
---

[[jpacontainer.filtering]]
= Filtering [classname]#JPAContainer#

Normally, a [classname]#JPAContainer# contains all instances of a particular
entity type in the persistence context. Hence, it is equivalent to a database
table or query. Just like with database queries, you often want to narrow the
results down. [classname]#JPAContainer# implements the
[interfacename]#Filterable# interface in Vaadin containers, described in
<<dummy/../../../framework/datamodel/datamodel-container#datamodel.container.filtered,"Filterable
Containers">>. All filtering is done at the database level with queries, not in
the container.

For example, let us filter all the people older than 117:


----
Filter filter = new Compare.Greater("age", 117);
persons.addContainerFilter(filter);
----
See the http://demo.vaadin.com/book-examples-vaadin7/book#jpacontainer.filtering.basic[on-line example, window="_blank"].

This would create a JPQL query somewhat as follows:


----
SELECT id FROM Person WHERE (AGE > 117)
----
See the http://demo.vaadin.com/book-examples-vaadin7/book#jpacontainer.filtering.basic[on-line example, window="_blank"].

The filtering implementation uses the JPA 2.0 Criteria API transparently. As the
filtering is done at the database-level, custom filters that use the
[interfacename]#Filterable# API do not work.

When using Hibernate, note that it does not support implicit joins. See
<<dummy/../../../framework/jpacontainer/jpacontainer-hibernate#jpacontainer.hibernate.joins,"Joins
in Hibernate vs EclipseLink">> for more details.