You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Next »

The Java Persistence API (JPA) is a new programming model under EJB3.0 specification (JSR220) for the management of persistence and object/relational mapping with Java EE and Java SE. With JPA, developers can easily develop java applications that perform operations on relational database management systems using java objects and mapping. In that way, java applications developed using JPA are not only portable across different platforms, but also applications can be easily developed using simple yet powerful programming model provided by JPA. This greatly improves application maintainability against ever changing database world. JPA insulates applications from all the complexity and non-portable boilerplate code involved in database connectivity and operations.

Apache geronimo uses OpenJPA for providing Java Persistence API to Java EE applications deployed in the server. Even though JPA is a part of EJB3.0 spec, it is independent of it. Hence, JPA can be used in JavaSE, web and ejb applications in the same uniform way.

The below section illustrates developing and deploying a JEE application client that uses JPA to access and manipulate database data residing in an embedded derby database.

In order to develop, deploy and run the application, the following environment is required.

  • Sun JDK 5.0+ (J2SE 1.5)
  • Eclipse 3.3.1.1 (Eclipse Classic package of Europa distribution), which is platform specific
  • Web Tools Platform (WTP) 2.0.1
  • Data Tools Platform (DTP) 1.5.1
  • Eclipse Modeling Framework (EMF) 2.3.1
  • Graphical Editing Framework (GEF) 3.3.1

The article has the following sections.

  • Setting up Eclipse for Application development
  • Developing Entities and Client
  • Preparing Deployment Descriptors and Deployment Plans
  • Deploying the application client
  • Running the application client

Setting Eclipse for Application development

1. Start the Eclipse IDE and create a Java project by name ApplicationClientJPA as follows.
Right click on the Project Explorer Window and click on New => Java Project.

Provide ApplicationClientJPA as the name for the Java Project.

Click on Next and Finish.

2. Right click on the Project and click on the Properties option which is the last option in the menu.

This will open up Properties Window. Click on Java Build Path => Libraries tab on the right hand side.

Click on Add External JARs button and browse for geronimo-jpa_3.0_spec-1.1.1.jar file in the geronimo
server repository. This file will be available at{{<geronimo_home>/repository/org/apache/geronimo/specs/
geronimo-jpa_3.0_spec/1.1.1}} folder.
The JPA annotations used in Account.java and some of the JPA classes used in AccountClient.java
requires this library at compile time. Click on the Open button.

This will add the library to the build path. Click on OK.

  • No labels