Vaadin JPAContainer can be installed either as an installation package, downloaded from the Vaadin Directory, or as a Maven dependency. You can also create a new JPAContainer-enabled Vaadin project using a Maven archetype.

The download page in Vaadin Directory gives the dependency declaration needed for retrieving the Vaadin JPAContainer library with Maven. A separate dependency declaration is given for both available licenses for Vaadin JPAContainer.

For the CVAL License:

<dependency>
   <groupId>com.vaadin.addon</groupId>
   <artifactId>jpacontainer-addon-cval-2.0</artifactId>
   <version>2.0.0</version>
</dependency>

For the AGPL License:

<dependency>
   <groupId>com.vaadin.addon</groupId>
   <artifactId>jpacontainer-addon-agpl-3.0</artifactId>
   <version>2.0.0</version>
</dependency>

Use the LATEST version tag to automatically download the latest stable release or use a specific version number as done above.

See Section 15.5, “Using Add-ons in a Maven Project” for detailed instructions for using a Vaadin add-on with Maven.

Persistence configuration is done in a persistence.xml file. In a regular Eclipse project, it should be located in WebContent/WEB-INF/classes/META-INF. In a Maven project, it should be in src/main/resources/META-INF. The configuration includes the following:

  • The persistence unit

  • The persistence provider

  • The database driver and connection

  • Logging

The persistence.xml file is packaged as WEB-INF/classes/META-INF/persistence.xml in the WAR. This is done automatically in a Maven build at the package phase.

The root element of the persistence definition is persistence-unit. The name of the persistence unit is needed for creating JPAContainer instances from a JPAContainerFactory, as described in Section 18.4.1, “Creating JPAContainer with JPAContainerFactory or when creating a JPA entity manager.

<persistence-unit name="addressbook">

Persistence provider is the JPA provider implementation used. For example, the JPAContainer AddressBook demo uses the EclipseLink JPA, which is defined as follows:

<provider>
    org.eclipse.persistence.jpa.PersistenceProvider
</provider>

The persistent classes need to be listed with a <class> element. Alternatively, you can allow including unlisted classes for persistence by overriding the exclude-unlisted-classes default as follows:

<exclude-unlisted-classes>false</exclude-unlisted-classes>

JPA provider specific parameters are given under the properties element.

<properties>
   ...

In the following section we give parameters for the EclipseLink JPA and H2 database used in the JPAContainer AddressBook Demo. Please refer to the documentation of the JPA provider you use for a complete reference of parameters.