Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The Java Persistence API 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. Below sections illustrate developing applications using JPA and how to write various deployment descriptors and plans for apache geronimo.

...

This example illustrates developing an enterprise application that uses JPA for persistence. The database used is the embedded derby shipped with apache geronimo. Here, we present a persistence deployment descriptor (persistence.xml) that contains database connectivity and other information for the application. The persistence.xml is placed under META-INF/ directory of the application archive. The application contains an ejb module and a web module. Ejb module uses a stateless session bean ShareHolderBean that uses JPA to perform database operations on the table SHAREACCOUNT in the ShareDB derby database. The SHAREACCOUNT table contains information about each shareholder along with the information regarding number shares he or she possesses currently in the account. The ShareHolderBean has methods that retrieve shareholder information, buy/sell shares of a particular shareholder, close the shareholder account etc. The web application has a servlet that looks up the {{ ShareHolderBean}} and trigger the operations on it. The deployment descriptor information for the ejb module is provided using Java EE annotations in the respective bean classes. However, the persistence deployment descriptor information is provided using META-INF/persistence.xml file.

...

  • The following data will be inserted into ACCOUNT table.
    No Format
    borderStylesolid
    titleACCOUNT table
    ACCOUNTNO ACCOUNTTYPE NAME ADDRESS BRANCHCODE INTERESTRATE MINBALANCE BALANCE CURRENTACCOUNTRULES SAVINGSACCOUNTRULES 
    1 CURRENTACCOUNT Joe Joe's address 10 20.00 200.00 5000.00 Current Account!!  
    2 SAVINGSACCOUNT Joe Joe's address 12 234.00 4534.00 13323.00  Savings Account!! 
    3 CURRENTACCOUNT John John's address 10 20.00 200.00 5000.00 Current Account!!  
    4 SAVINGSACCOUNT John John's address 12 234.00 4534.00 13323.00  Savings Account!!
    

...