Java Reference
In-Depth Information
Chapter 5. Combining Persistence with
CDI
In earlier chapters we covered lots of Java EE ground, combining several technolo-
gies such as the CDI API. The examples so far, however, are based on a false as-
sumption - that all the information can be stored in memory. In this chapter, we will
show how to use a persistent data store for our application in the form of a standard
relational database.
The Enterprise JavaBeans ( EJB ) 3.0 specification includes a persistence specifica-
tion called the Java Persistence API ( JPA ). It is an API for creating, removing, and
querying Java objects called entities that can be used within both a compliant EJB
3.0 Container and a standard Java SE environment.
There is a lot of ground to cover in this chapter and concepts will be coming at you
from every direction. But at the end of it, you will be able to appreciate exactly how to
create and deploy a complete Java EE 6 application.
Specifically, we will discuss the following topics:
• The key elements of JPA
• How to create your entities, starting with database tables
• How to manipulate the entities using CDI Beans and EJBs
• Delivering a frontend tier for our application using JSF and Facelets tech-
nology
Data persistence meets a standard
The arrival of an Enterprise Java Persistence standard based on the Plain Old
Java Object ( POJO ) development model fills a substantial gap in the Java EE plat-
form. The previous attempt (the EJB 2.x specification) missed the mark and created
the stereotype of EJB entity beans being awkward to develop and too heavy for many
applications. Therefore, it never achieved widespread adoption or general approval in
many sectors of the industry.
Search WWH ::




Custom Search