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
- Open a Java source
file containing a class that you want to convert to a JPA entity bean.
- In the Java editor,
add one of the following JPA annotations immediately before the class
declaration:
- @Entity
- @Embeddable
- @Mappedsuperclass
- 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.
- 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.
- Press Ctrl+S to save the class file.
- Switch to the JPA Development perspective (), finish creating
the new JPA entity bean, and create additional entities as needed.