Java Persistence Tasks: Quick Reference

This topic describes common tasks you do to implement Java Persistence in your project. For more detailed information, click the links in the right column.

To perform this task Follow these steps
Create a persistence unit in a web module or EJB module.
  1. Choose File > New File (Ctrl-N).
  2. In the New File wizard, select the Persistence Unit file type in the Persistence category and click Next.
  3. Enter a unique name for the persistence unit or use the default name.
  4. Choose a persistence provider and data source.
  5. Click Finish.
Create an entity class.
  1. In the Projects window, right-click the project module node and choose New > Other.
  2. Select Entity Class from the Persistence category.
Create entity classes from a database.
  1. In the Projects window, right-click the project module node and choose New > Other.
  2. Select Entity Classes from Database from the Persistence category.
Create JPA controller classes from entity classes.
  1. In the Projects window, right-click the project module node and choose New > Other.
  2. Select JPA Controller Classes from Entity Classes from the Persistence category.
Add support for the Java Persistence API to project's classpath.
  1. In the Projects window, right-click the project's Libraries node and choose Add Library.
  2. Select the EclipseLink library.
Add an entity manager.
  1. Open the class where you want to inject the entity manager.
  2. In the Source Editor, right-click in the class and choose Persistence > Use Entity Manager.

Legal Notices