O'Reilly logo

Java EE 7 with GlassFish 4 Application Server by David R. Heffelfinger

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Introducing the Java Persistence API

JPA was introduced to Java EE in Version 5 of the specification. As its name implies, it is used to persist data to an RDBMS. JPA is a replacement for Entity Beans that were used in J2EE. JPA Entities are regular Java classes; the Java EE container recognizes these classes as JPA entities. Let's look at an Entity mapping to the CUSTOMER table in the CUSTOMERDB database, shown in the following code:

package net.ensode.glassfishbook.jpaintro.entity; import java.io.Serializable; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.Table; @Entity @Table(name = "CUSTOMERS") public class Customer implements Serializable { @Id @Column(name = "CUSTOMER_ID") ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required