This Cloud Tutorial is the third of a series building a web application step by step with Java EE technology. It will see us implement the persistence layer of the application. We explain how to use the Java Persistance API (JPA) to define the object-relational mapping and to persist entities to the relational H2 data base using the container managed transactional behavior of Enterprise JavaBeans (EJBs). Further, we describe how to use the Bean Validation API (BV) to unify JSF and JPA validation.

Who is this Cloud Tutorial for?

The Cloud Tutorial is dedicated to anyone who wants to make his first steps towards getting an expert in the Java EE environment. A solid knowledge of the Java programming language and basic know-how about HTML and XML is required. Ideally, the reader has already worked off our Cloud Tutorial Java EE in a Day. As the given sample application is based on JSF (JavaServer Faces) and CDI (Contexts and Dependency Injection), it is advisable to have some basic knowledge about these technologies, but it would not be mandatory. If you want to dig deeper into these topics, we recommend reading our Cloud Tutorials JavaServer Faces in a Day and CDI in a Day.

Our concept

From our experience, while getting used to a new topic, learners spend a lot of time with setup and configuration. Before writing a single line of code, SDKs, IDEs, application servers and other tools must be installed and configured and, in most cases, a project skeleton must be written.
All these are no fun tasks… Although necessary in the real-world, they don’t transfer any real knowledge about the subject.

Therefore, we are using the cloud IDE Codenvy to provide a ready-to-run preconfigured development environment whenever necessary.

At the beginning of each chapter you just have to click on the provided Codenvy link and a fully configured IDE will be started in a new browser tab, with the right changes already made and containing the programming code needed for the following task. The reader uses a combination of an online textbook and a cloud IDE. That’s what we call a Cloud Tutorial.

Learning a new technology never has been easier!

Theroretical Background and Our Sample Application

In the following Cloud Tutorial, we will improve the architecture and design of the given sample application “My-Campaign” using the JPA, EJB and BV. The Cloud Tutorial is the third of a series that gives an introduction to Java EE 7 in a whole. The series starts with developing user interfaces using JSF, continues with realizing a flexible controller architecture using CDI, shows realizing persistence with JPA and EJB and, finally, shows how to develop REST services for the application. You can either work off the whole series sequentially or you can get in at the point of your choice. In any case, you should first get familiar with the theoretical background of Java EE and the requirements of the sample application before you continue.


Use the message board below to give the authors your feedback or to discuss this page’s topic with other readers (in English please!). Please don’t expect the authors to answer directly, but they might update the content of this site according to your feedback.