Directory

← Back

Vaadin JPAContainer

Binds Vaadin user interface components directly to your JPA entities. Use Criteria API to modify database queries and automatically created fields for referenced entities.

Author

Rating

Popularity

100+

Note, this add-on is depracated. Version 4.0.0, compatible with Vaadin Framework 8.0.0, is only built to make it easier to upgrade to Vaadin 8 using compatibility packages. The new version only changed relevant imports into v7 compatibility package. Users are encouraged to move to more modern Vaadin 8 APIs.

Vaadin JPAContainer allows connecting Vaadin user interface components directly to the persistent model objects. It is an implementation of the container interface defined in the Vaadin core framework. You can use JPAContainer to display data in a table, tree, any other selection component, or edit the data in a form. JPAContainer uses 3rd party JPA 2.0 (JSR-317) standard supporting Object-Relational Mapping (ORM) libraries, such as EclipseLink or Hibernate, for storing and retrieving data from database.

Vaadin JPAContainer suits well for trivial listings of one Entity. In most cases JPA should though be used with Vaadin through a service layer and entities should be bound to components like any other Java objects, with for example BeanItemContainer. For lazy loading solutions with this kind of architecture, there are excellent community contributed add-ons like Viritin and LazyQueryContainer, which are often used instead of JPAContainer by projects built here at Vaadin Ltd as well.

Vaadin JPAContainer 2.0 supports the most common features required by Java EE applications out of the box, such as lazy loading, advanced filtering, nested property names and caching. JPAContainer utility classes makes writing CRUD functionality to your application fast and easy. E.g. use automatically created selects or “master-detail views” for ManyToOne or OneToMany relations.

In case you are still using JPA 1.0 implementation you should use older version of JPAContainer which can be downloaded by selecting 1.2.x version from Version drop-down list.

Note, some new features of the add-on (like the FieldFactory) requires Vaadin 6.7.3 or later.

Sample code

		JPAContainer<Person> container = JPAContainerFactory.make(Person.class, "addressbook");
		Table table = new Table("Persons", container);
/**
 * Example entity. When bound to a Form with FieldFactory from JPAContainer
 * add-on:
 * 
 * - customer will be edited a select of customers backed by JPAContainer
 * listing Customer entities
 * 
 * - rows will be edited with a Table based "master-detail editor" backed up
 * JPAContainer listing InvoiceRows related to this entity
 * 
 * - billingAddress will be edited with a sub form
 * 
 * See related screenshot for the result
 * 
 */
@Entity
public class Invoice {
    
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;
    @Temporal(TemporalType.TIMESTAMP)
    private Date date;
    @ManyToOne
    private Customer customer;
    @OneToMany(mappedBy="invoice")
    private List<InvoiceRow> rows;
    @OneToOne
    private BillingAddress billingAddress;

    // getters and setters omitted

}

Form form = new Form();

// use the FieldFactory helper class from JPAContainer Add-On
FieldFactory jpaContainerFieldFactory = new FieldFactory();
form.setFormFieldFactory(jpaContainerFieldFactory);

// set item to form from a JPAContainer instance
form.setItemDataSource(jpaContainer.getItem(itemId);

Compatibility

(Loading compatibility data...)

Was this helpful? Need more help?
Leave a comment or a question below. You can also join the chat on Discord or ask questions on StackOverflow.

Version

Only change from 3.2 is that 4.0 uses v7 compatibility package for imports, making it easier to migrate to Vaadin 8.

Released
2017-03-02
Maturity
CERTIFIED
License
Apache License 2.0

Compatibility

Framework
Vaadin 8.0+
Vaadin 6.2+ in 0.9.0
Vaadin 6.0+ in 1.0.5
Vaadin 6.6+ in 1.1.0
Vaadin 6.7+ in 2.0.0-RC1
Vaadin 6.8+ in 2.2.0
Vaadin 7.0+ in 3.0.0-alpha1
Vaadin 7.1+ in 3.1.0
Vaadin 7.2+ in 3.2.0
Browser
Browser Independent

Vaadin JPAContainer - Vaadin Add-on Directory

Binds Vaadin user interface components directly to your JPA entities. Use Criteria API to modify database queries and automatically created fields for referenced entities. Vaadin JPAContainer - Vaadin Add-on Directory
*Note, this add-on is depracated. Version 4.0.0, compatible with Vaadin Framework 8.0.0, is only built to make it easier to upgrade to Vaadin 8 using compatibility packages. The new version only changed relevant imports into v7 compatibility package. Users are encouraged to move to more modern Vaadin 8 APIs.* Vaadin JPAContainer allows connecting Vaadin user interface components directly to the persistent model objects. It is an implementation of the container interface defined in the Vaadin core framework. You can use JPAContainer to display data in a table, tree, any other selection component, or edit the data in a form. JPAContainer uses 3rd party JPA 2.0 (JSR-317) standard supporting Object-Relational Mapping (ORM) libraries, such as EclipseLink or Hibernate, for storing and retrieving data from database. *Vaadin JPAContainer suits well for trivial listings of one Entity. In most cases JPA should though be used with Vaadin through a service layer and entities should be bound to components like any other Java objects, with for example BeanItemContainer. For lazy loading solutions with this kind of architecture, there are excellent community contributed add-ons like [Viritin](https://vaadin.com/addon/viritin) and [LazyQueryContainer](https://vaadin.com/addon/lazy-query-container), which are often used instead of JPAContainer by projects built here at Vaadin Ltd as well.* Vaadin JPAContainer 2.0 supports the most common features required by Java EE applications out of the box, such as lazy loading, advanced filtering, nested property names and caching. JPAContainer utility classes makes writing CRUD functionality to your application fast and easy. E.g. use automatically created selects or “master-detail views” for ManyToOne or OneToMany relations. In case you are still using JPA 1.0 implementation you should use older version of JPAContainer which can be downloaded by selecting 1.2.x version from Version drop-down list. Note, some new features of the add-on (like the FieldFactory) requires Vaadin 6.7.3 or later.
Tutorial
Add-on Homepage
JPA best practices webinar
Issue Tracker
Source Code
Discussion Forum

Vaadin JPAContainer version 0.9.0
null

Vaadin JPAContainer version 0.9.1
null

Vaadin JPAContainer version 1.0.0
null

Vaadin JPAContainer version 1.0.1
null

Vaadin JPAContainer version 1.0.3
Removed unnecessary Maven dependency, predictable embedded ID field order across JRE versions

Vaadin JPAContainer version 1.0.4
Handle mapped superclasses better, use merge() to save new entities

Vaadin JPAContainer version 1.0.5
Packaging changes

Vaadin JPAContainer version 1.1.0
Vaadin 6.6 filtering support - for older Vaadin versions, use JPAContainer 1.0.x

Vaadin JPAContainer version 1.1.1
Vaadin 6.6 filtering support, built with Maven - for older Vaadin versions, use JPAContainer 1.0.x

Vaadin JPAContainer version 1.1.2
Support for primitive data types.

Vaadin JPAContainer version 1.2.0
License update - CVAL 2.0 instead of 1.0

Vaadin JPAContainer version 1.2.1
Reference/embedded/collection properties are not sortable by default, option to make them sortable based on a user-defined property

Vaadin JPAContainer version 2.0.0-RC1
JPA 2.0 support, enhanced productivity and bugfixes, see the add-on homepage for more details.

Vaadin JPAContainer version 2.0.0
JPA 2.0 support, enhanced productivity and bugfixes, see the add-on homepage for more details.

Vaadin JPAContainer version 2.1.0
Improved JEE6 support and bugfixes.

Vaadin JPAContainer version 3.0.0-alpha1
This is first alpha release of Vaadin JPAContainer that is compatible with Vaadin 7. This release is built against Vaadin 7.0.0.beta2. The upgrade of this add-on is on its early stages. Previous features are tested to work in simple cases. E.g. listing entities in Table and editing them in the legacy Form works, but there are still lot of things that we plan to do with this add-on before final release. New features like completely redesigned “forms” in Vaadin 7 have paved way for huge improvements in JPAContainer. Before stable release there will be major new features and also expect that some current ones will be dropped.

Vaadin JPAContainer version 3.0.0-alpha2
An alpha release built against Vaadin 7 beta 11. No major changes.

Vaadin JPAContainer version 2.2.0
The license has changed to Apache 2.0

Vaadin JPAContainer version 3.0.0
Compatibility with Vaadin 7. Note that JPAContainer is now released under the Apache license v2.0!

Vaadin JPAContainer version 3.1.0
Vaadin 7.1 compatibility (for Vaadin 7.0, use JPAContainer 3.0)

Vaadin JPAContainer version 3.2.0
Compatibility fixes with Vaadin 7.2.0 and newer.

Vaadin JPAContainer version 4.0.0
Only change from 3.2 is that 4.0 uses v7 compatibility package for imports, making it easier to migrate to Vaadin 8.

Online