Applications that use JPA can be created in the following ways, depending on the provision format:
Library
Select this method if the program that uses JPA is provided as a component.
Embedded in EJB or a Web application
Select this method if used only by EJB or a Web application and if the interface of the program that uses JPA is not strictly prescribed.
After the provision format is determined, create the project and set the required library in the project, then prepare an environment that enables the build.
Point
Support functions for constructing a database connection environment, for generating an Entity class from a database tables, and for other tasks can be used when developing applications that use JPA.
For details, refer to "8.3.1 Connecting to the Database" for details of constructing a database connection environment. The connection information for the constructed database is used in the setup of information concerning JPA. For details, refer to "4.3.1.1 Setting the JPA Facet" for details.
Creating the Project
Use the Project wizard to create the project that corresponds to the application that uses JPA. The Project wizard includes a [Project Facets] page. On this page, select the required [Java Persistence] project facet.
Projects are described below.
Web application
If the JPA is to be used in a Web application, create a dynamic Web project. Select [Web] > [Dynamic Web Project] from the [New Project] wizard.
For details, refer to "2.3.1 Preparing the Environment for Creating the Web Application" for details of the Dynamic Web project wizard.
EJB application
If the JPA is to be used in an EJB application, create an EJB project. Select [EJB] > [EJB Project] from the [New Project] wizard.
For details, refer to "3.3.1 Preparing the Environment to create EJBs" for details of the EJB project wizard.
Library
If the program that uses JPA is to be provided as a library, create a JPA project. Select [JPA] > [JPA Project] from the [New Project] wizard.
For details, refer to "6.2.2.1 Creating New Projects" for details of the common parts of the Project wizards.
If the [Java Persistence] project facet was selected, information related to JPA can be set. For details, refer to "4.3.1.1 Setting the JPA Facet" for details of the settings for JPA-related information.
Point
If you want to use JPA in an existing EJB project or dynamic Web project, add [Java Persistence]from [Project Facets] in the project properties, then set the JPA-related information.
For details, refer to "4.3.1.1 Setting the JPA Facet" for details of the settings for JPA-related information.
Classpath Settings
Classpaths must be set if there are libraries or similar that are required in order to create the application. Classpaths are set in the project build path.
For details, refer to "6.2.2.3 Setting Classpaths" for details of build path settings.
If the [Java Persistence] project facet is added to a project, use the Project wizard or the Facet Addition wizard to set the following JPA-related information:
Connection
Database connection can be set in the project. However, an application that uses JPA can be created even if the database connection is not set.
For details, refer to "8.3.1 Connecting to the Database" for details of database connection.
JPA implementation
Specify the JPA implementation class. Select whether the implementation provided by the server runtime or the implementation library is used.
Persistent class management
Select whether management is achieved by coding the Entity class in persistence.xml, or whether the annotation class is automatically detected without the Entity class being coded in persistence.xml.
Create orm.xml
Select whether or not an O/R mapping file is created.
Point
Connection and persistent class management can also be specified from [JPA] under the project properties.