Assembling JPA applications for a Java SE environment
You have developed and configured the applications to work with the Java Persistence API (JPA). Now package the JPA applications for the environment.
For this task, you must specify the com.ibm.ws.jpa.thinclient_8.0.0.jar stand-alone Java archive (JAR) file in our class path. This stand-alone JAR file is available from the client and server installation images. The location of this file on the client installation image is ${ app_client_root}/runtimes/com.ibm.ws.jpa.thinclient_8.0.0.jar. The location of this file on the server installation image is ${ app_server_root}/runtimes/com.ibm.ws.jpa.thinclient_8.0.0.jar.
- Package the application.
Package the persistence units in separate JAR files to make them more accessible and reusable. If we package the persistence units this way, they can be tested outside the container both with and without the occurrence of database persistence. The persistence units can be included in stand-alone applications or they can be packaged into EAR files as persistence archive files. If we package the persistence unit into a persistence archive file, all of the application components must be able to access the persistence archive. The application that uses the persistence units must declare a dependency on the persistence archive using the MANIFEST.MF Class-Path: declaration.
The Criteria Metamodel class files that are generated by the Annotation Processor when you developed the JPA application, must be included in the JAR file in the same location as the entity class files.
If we are using IBM Optimâ„¢ PureQuery Run time, add the persistence_unit_name.pdqxml files to the JPA application JAR file. The files are located in same META-INF directory where the persistence.xml file is located. These persistence files were created during the development task, Developing JPA applications for a Java SE environment. To package the application use the following command:
jar -cvf ${jar_Name} ${entity_Path}
where ${jar_Name} represents the name of the JAR file to create, and ${entityPath} represents the root location where the entities reside, which is where you compiled them. Make sure the ${entity_Path} also contains the META-INF/persistence.xml file.
- When you run the stand-alone application, specify the JAR files in the class path when starting the application. The JPA runtime starts the stand-alone JAR file, com.ibm.ws.jpa.thinclient_8.0.0.jar. For example, use the following Java call to run the com.xyz.Main stand-alone application:
java -cp /your/directory/${jar_Name} -javaagent:${ app_client_root}/runtimes/com.ibm.ws.jpa.thinclient_8.0.0.jarcom.xyz.Main
What to do next
For more information about any of the commands, classes or other OpenJPA information, refer to the Apache OpenJPA User Guide.
Related tasks
Develop JPA 2.x applications for a Java SE environment Task overview: Storing and retrieving persistent data with the JPA API
Related information:
Apache OpenJPA User Guide