Binding JPA data to a JSF component

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

  1. In the Data and Services drawer of the Palette, drag JPA Data onto the Web page. The Add JPA data to page wizard opens.
  2. Select the JPA Manager that you want to use in your page.
    Note: Alternatively you can create a new JPA Manager:
    1. Click Create new JPA Manager. The JPA Manager Bean wizard opens.
    2. Click Create New JPA Entities. The Generate Entities wizard opens.
    3. Specify your database connection settings then click Next.
    4. On the Generate Entities from Tables page of the wizard, type a package name.
    5. Click Synchronize Classes in persistence.xml.
    6. In the Tables list, select the tables for which you want to generate entities. Click Finish.
    7. In the JPA Manager Bean wizard, select the entities for which you want to generate manager beans. Click Next.
    8. For each of the manager beans, specify the primary key. Click Finish.
    9. Select the JPA Manager that you want to use in your page.
  3. 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.
  4. Click Next.
  5. 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.
  6. 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).

Feedback