Java Reference
In-Depth Information
Creating our first JPA entity
JPA entities are Java classes whose fields are persisted to a database by the JPA API.
These Java classes are
Plain Old Java Objects
(
POJOs
), and as such, they don't need
to extend any specific parent class or implement any specific interface. A Java class is
designated as a JPA entity by decorating it with the
@Entity
annotation.
In order to create and test our first JPA entity, we will create a new web application
using the JavaServer Faces framework. In this example, we will name our application
jpaweb
, and (as with all of our examples) we will use the bundled GlassFish
application server.
Refer to
Chapter 2
,
Developing Web Applications Using JavaServer Faces
2.2
, for instructions on creating a new JSF project.
To create a new JPA entity, select the
Persistence
category from the new file dialog
and select
Entity Class
as the file type.