Generating JPA Controller Classes from Entity Classes

See Also

A JPA controller class is a wrapper for an entity class that provides clients with access to the database through the methods in the entity class. The JPA controller class contains the logic for creating, editing and destorying an entry in the data source, getting all of the entries in the data source, and getting a specific entry in the data source.

The JPA Controller Classes from Entity Classes wizard generates JPA controllers based on entity classes in your application. The wizard generates one JPA controller class for each entity class that you select and places the controller class in the specified location. Each generated JPA controller class contains create, edit and destroy methods and methods for retrieving the entities and uses an entity manager for managing entity persistence. The wizard also generates exception classes used by the controller classes.

To generate a JPA controller class from an entity class:

  1. Choose File > New (Ctrl-N) from the main menu.
  2. From the Persistence category, select JPA Controller Classes from Entity Classes and click Next. The wizard displays all of the entity classes in the project.
  3. Add all of the entity classes for which you want to generate controller classes to the Selected Entity Classes list and click Next.
  4. Specify a package for the JPA controller classes. The default location is the folder containing the selected entity classes.
  5. Click Finish.

After the wizard generates the JPA controller classes, the controller methods can be invoked from JSP pages or JSP converters or other classes in your application. If the database schema changes you can use the IDE wizards to again generate new entity classes and controller classes and then where necessary update the code that invokes the controller methods.

See Also
Generating JSF Pages from an Entity Class
About CRUD Applications
Creating an Entity Class
Generating Persistent Entity Classes from a Database

Legal Notices