You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

jpacontainer-filtering.asciidoc 1.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. ---
  2. title: Filtering JPAContainer
  3. order: 6
  4. layout: page
  5. ---
  6. [[jpacontainer.filtering]]
  7. = Filtering [classname]#JPAContainer#
  8. Normally, a [classname]#JPAContainer# contains all instances of a particular
  9. entity type in the persistence context. Hence, it is equivalent to a database
  10. table or query. Just like with database queries, you often want to narrow the
  11. results down. [classname]#JPAContainer# implements the
  12. [interfacename]#Filterable# interface in Vaadin containers, described in
  13. <<dummy/../../../framework/datamodel/datamodel-container#datamodel.container.filtered,"Filterable
  14. Containers">>. All filtering is done at the database level with queries, not in
  15. the container.
  16. For example, let us filter all the people older than 117:
  17. ----
  18. Filter filter = new Compare.Greater("age", 117);
  19. persons.addContainerFilter(filter);
  20. ----
  21. See the http://demo.vaadin.com/book-examples-vaadin7/book#jpacontainer.filtering.basic[on-line example, window="_blank"].
  22. This would create a JPQL query somewhat as follows:
  23. ----
  24. SELECT id FROM Person WHERE (AGE > 117)
  25. ----
  26. See the http://demo.vaadin.com/book-examples-vaadin7/book#jpacontainer.filtering.basic[on-line example, window="_blank"].
  27. The filtering implementation uses the JPA 2.0 Criteria API transparently. As the
  28. filtering is done at the database-level, custom filters that use the
  29. [interfacename]#Filterable# API do not work.
  30. When using Hibernate, note that it does not support implicit joins. See
  31. <<dummy/../../../framework/jpacontainer/jpacontainer-hibernate#jpacontainer.hibernate.joins,"Joins
  32. in Hibernate vs EclipseLink">> for more details.