Java™ Persistence
API (JPA) is a specification for the persistence of Java objects to relational databases. JPA allows
you to manage relational data in enterprise applications.
About this task
To create a JPA object in a JSF page:
Procedure
- In the Data and Services drawer of the Palette, drag JPA Data onto the Web page. The Add
JPA data to page wizard opens.
- Select the JPA Manager that you want to use in your page.
Note: Alternatively you can create a new JPA Manager:
- Click Create new JPA Manager. The JPA Manager
Bean wizard opens.
- Click Create New JPA Entities. The Generate
Entities wizard opens.
- Specify your database connection settings then click Next.
- On the Generate Entities from Tables page of the wizard, type
a package name.
- Click Synchronize Classes in persistence.xml.
- In the Tables list, select the tables for which you want to generate
entities. Click Finish.
- In the JPA Manager Bean wizard, select the entities for which
you want to generate manager beans. Click Next.
- For each of the manager beans, specify the primary key. Click Finish.
- Select the JPA Manager that you want to use in your page.
- Select a method for displaying the data:
- If you want to display a list of data, click Retrieve
a list of data.
- If you want to display a single record, click Retrieve
a single record.
- If you want to create a form that can create a new record,
click Create a new record.
- If you want to create a form that enables you to update an
existing record, click Update an existing record.
- Click Next.
- Select the query that will retrieve the data that you want
to display. Click Next until you get to the
Configure data controls page of the wizard.
Important: This step only applies to displaying a list of data
and displaying a single record.
- Specify how you want to display the data on your Web page.
You can add and remove data, reorder the fields, change the labels,
and change some of the control types. Click Finish.
What to do next
For more information about displaying and updating JPA data
on a Web page, refer to
Accessing data using Java Persistence API (JPA).