Creating JPA entity beans
You can create JPA entity beans from existing database tables or you can create JPA entity beans then generate database tables from the JPA entity beans.
Creating JPA entity beans from existing database tables
Create a JPA enabled dynamic Web project.
To create a JPA entity bean from existing database tables:
- In Enterprise Explorer, right-click your JPA enabled Web project and select
JPA Tools | Generate Entities. The Generate Entities wizard opens.
- On the Database Connection page of the wizard, specify the connection name and the connection schema. Click Next.
- On the Generate Entities from Tables page of the wizard, type a package name.
- Click
Synchronize Classes in persistence.xml. This option enables automatic synchronization of the persistence.xml with any JPA resources in your workspace.
- In the Tables list, select the tables for which you want to generate entities. Click Finish.
The JPA entity beans are added to your Web project. You can view them in the JPA Content node.
Generating database tables from JPA entity beans
Create a JPA enabled dynamic Web project.
To generate database tables from entity beans:
- Create a JPA entity bean.
- Generate a data definition language (DDL) file.
- Create a database connection for the project:
- Right-click your Web project and select
Properties.
- From the Properties list, click
JDBC Connections.
- Click
New. Follow the instructions in the wizard to create a connection to a database.
- Generate database tables from the DDL file.