Directory

JPA Criteria Lazy Container - Vaadin Add-on Directory

JPA 2.0 Criteria API extension to Lazy Query Container add-on JPA Criteria Lazy Container - Vaadin Add-on Directory
This add-on uses JPA 2.0 type-safe queries written using the Criteria API, that automatically generate SQL for the programmer. The containers in this add-on automatically figure out the properties for the container, no manual step is required. In simple situations that involve only one table, no query programming is needed, and the Vaadin Filterable and Sortable mechanisms are directly supported. The CriteriaContainer class supports this usage. It is also possible to program queries for grouping, sorting, filtering and any situation where more control is required. CriteriaContainer supports the addition of entities to the container., A second container allows retrieval of joined tables, and the creation of containers where a given item comes from any number of joined entities and computed values. The BeanTupleContainer supports this generalized access. Also, each of the entities returned is editable. When an entity appears in several tuples, it is the same entity -- changing the entity will be reflected everywhere when the item is written and the container refreshed. When using BeanTupleContainer, adding entities is done using the JPA API persist() function, and refreshing the container. Nested properties are supported. For example, if the Person entity is joined to the Task entity via the assignedTo relationship, it will be possible to retrieve all the Person,Task pairs for which this relationship is true, and the item will allow retrieval of Person.name and Task.dueDate as item properties if these fields are present in the entities. The full Jakarta PropertyUtils syntax is supported, so you can also invoke getters on the retrieved objects.
Source code for sample app
Source code for add-on
Sample application WAR (with libs)
Issue Tracker
Release notes
Javadoc

JPA Criteria Lazy Container version 0.1.0
Release notes upcoming.

JPA Criteria Lazy Container version 0.1.1
Sorting had not been enabled. Now fixed.

JPA Criteria Lazy Container version 0.4.1
The main container is now BeanTupleContainer. An arbitrary criteria query can be used to retrieve a JPA Tuple; for normal usage, the JPA Tuple will contain one or more entities, and computed values. The entities retrieved in the tuple can be edited. For retrieving a single kind of entity, use CriteriaContainer - CriteriaContainer has been rebuilt on top of BeanTupleContainer - CriteriaContainer infers automatically the properties of the container - CriteriaContainer supports adding items. Improvement in the API for FilterRestriction to make it possible to filter on any selection in the returned tuple. Updated Javadoc Demos have been fixed. TupleContainer has been subsumed by BeanTupleContainer and removed.

JPA Criteria Lazy Container version 0.4.2
tiny fix to CriteriaContainer.addEntity()

JPA Criteria Lazy Container version 0.4.3
- properties inferred from query were not always automatically added to container - a call to container.refresh() was sometimes needed to trigger display in a table.

JPA Criteria Lazy Container version 0.4.5
- Added setKeyPropertyId(). Instead of returning the index in the container, getValue will return the value of the indicated property. This makes it easy to use Select and similar components to retrieve the actual foreign key - Fixed a bug related to refreshing tables after sorting. The "startingAt" index used internally for database retrieval was not always reset correctly.

JPA Criteria Lazy Container version 0.4.6
CriteriaContainer now supports nested retrieval container.addContainerProperty("assignee.class",...); table.setVisibleColumn("assignee.class"); The items of the container will then retrieve the value of assignee.getClass() when accessing the "assignee.class" property. Any string that can be understood by Jakarta PropertyUtils.getProperty can be used (e.g. person.address.zipcode or even person.children[0]). CriteriaContainer now supports setKeyPropertyId(). The designated property will be used as item identifier. This enables getValue() to return a value from the entity (a foreign key) instead of the index in the container. This is especially useful with Select and similar components.

JPA Criteria Lazy Container version 0.5.0
* Added support for isDetachedEntities() as in LazyQueryContainer 1.2.8. If this parameter is set, the entities loaded are immediately detached, and a merge() is performed on update and remove. Added corresponding constructors to BeanTupleQueryDefinition, CriteriaQueryDefinition and CriteriaContainer. * Further improvements caching of query size to avoid unnecessary calls to select count() * Improved defensive programming if asking to load empty or negative count of items. * Improved runtime error message if a CriteriaQueryDefinition is used on a BeanTupleContainer, since the conventions for property names are different and this can lead to hard to diagnose problems.

JPA Criteria Lazy Container version 0.9.0
Support for EclipseLink, support for Vaadin 6.6 Filterable interface. See link at right of this page for full release notes.

JPA Criteria Lazy Container version 0.9.2
Tested with FilteringTable add-on. Adding/removing a filter now causes a refresh.