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. |
- Choose File > New File (Ctrl-N).
- In the New File wizard, select the Persistence Unit file type in the Persistence category and click Next.
- Enter a unique name for the persistence unit or use the default name.
- Choose a persistence provider and data source.
- Click Finish.
|
Create an entity class. |
- In the Projects window, right-click the project module node and choose New > Other.
- Select Entity Class from the Persistence category.
|
Create entity classes from a database. |
- In the Projects window, right-click the project module node and choose New > Other.
- Select Entity Classes from Database from the Persistence category.
|
Create JPA controller classes from entity classes. |
- In the Projects window, right-click the project module node and choose New > Other.
- Select JPA Controller Classes from Entity Classes from the Persistence category.
|
Add support for the Java Persistence API to project's classpath. |
- In the Projects window, right-click the project's Libraries node and choose Add Library.
- Select the TopLink Essentials library.
|
Add an entity manager. |
- Open the class where you want to inject the entity manager.
- In the Source Editor, right-click in the class and choose Persistence > Use Entity Manager.
|