Converting a Java project to a JPA project

You can convert a plain Java™ project to a JPA-enabled project.

About this task

To convert a Java project to a JPA project:

Procedure

  1. Open a Java source file containing a class that you want to convert to a JPA entity bean.
  2. In the Java editor, add one of the following JPA annotations immediately before the class declaration:
    • @Entity
    • @Embeddable
    • @Mappedsuperclass
  3. You can see a Quick Fix (light bulb) icon next to the annotation that you typed. Click the Quick Fix icon or press Ctrl+1 to view the suggestion for how to correct the problem.
  4. Click the Add JPA support suggestion.
    The Java project is converted to a JPA project, the appropriate import statement is added to the class file for the annotation that you typed, and the class file is added to the persistence.xml file.
  5. Press Ctrl+S to save the class file.
  6. Switch to the JPA Development perspective (Window > Open Perspective > JPA Development), finish creating the new JPA entity bean, and create additional entities as needed.