You have developed and configured your applications to
work with the Java Persistence
API (JPA). Now you need to package the JPA applications for your environment.
About this task
Procedure
Package the application. There are several packaging
options for an application that uses JPA in a Java EE environment. Choose the packaging option
that best suits the JPA usage and configuration within the modules
of your application. These are some of the most common packaging options.
For a definitive list of packaging options, see the Java Persistence API specification.
Note: If
you are using IBM Optim pureQuery Runtime, add the persistence_unit_name.pdqxml files
to the JPA application JAR file. The files are located in same META-INF
directory where your persistence.xml file is located. These
persistence files were created during the development task. See the
topic, Developing JPA applications for a Java EE environment for more
information.
- For a standalone Enterprise JavaBeans (EJB)
module or a standalone application client module, package the EJB
and application client modules in a standard Java archive (JAR) file. Ensure that you package
the application with these conditions:
- The JAR file must contain your EJB class files or the Java class files for the application client.
- The META-INF directory of the archive must include your persistence.xml file.
- If your application uses mapping files, orm.xml, or a custom mapping
file, the JAR file must also contain those files. If the location
of the orm.xml file is not specified in the persistence unit,
the default location is the META-INF directory of the JAR file.
newfeatThe Criteria
Metamodel class files that are generated by the Annotation Processor
when you developed your application needs to be included in the JAR
file in the same location as the entity class files.
- For a standalone Web module, package the application in a
standard Web Application archive (WAR) file. Ensure that you package
the application with these conditions:
- For enterprise application that contains one or more modules,
package the application in a standard Enterprise application archive
(EAR) file. An enterprise application can contain one ore more EJB
module, Web module, or application client module. Ensure that you
package the application with these conditions:
What to do next
For more information about the commands, classes or other
OpenJPA information, refer to the Apache OpenJPA User's Guide.