---
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.



