Leveraging OPENJPA via WebSphere application Server V6.1

Source: Internet
Author: User
Tags websphere application server java se advantage

Introduction

The EJB 3.0 specification makes a significant (some say necessary) transformation of the EJB programming model. The entire EJB programming model, which focuses on the use of annotated common Java objects (plain old Java Object,pojo), is fundamentally different from the previous EJB specification. One aspect of this new programming model that gets a lot of attention is the persistence architecture. This article presents a complete example of this new Java Persistence API, which demonstrates how to leverage some of the functionality of the API now through the WebSphere application Server V6.1.

A brief overview of JPA

The Java Persistence API (JPA) is part of the Java EE 5 EJB 3.0 (EJB 3) series specification. The EJB 3 Expert group presented three specifications:

EJB Core Contracts and Requirements

EJB 3.0 Simplified API

Java Persistence API

The JPA specification defines persistent management and object/relationship mapping with Java EE and the Java SE environment.

In short, the JPA specification covers the following key areas:

Introduced a new POJO programming model that also works with Java EE and the Java SE environment. In addition to using an xml-based mechanism, you can now use annotations to define metadata directly in your application. In addition, entity POJO no longer needs to implement any interfaces based on the EJB framework.

The programming model also defines the separation model of the POJO (entity) object. This should be an advantage for the client/server and WEB application environments.

In addition to the enhanced EJB Query Language (EJB query Language, also known as JPQL), the programming model also supports the use of native SQL queries.

The JPA specification also explicitly defines object/relationship (O/R) mappings, rather than relying on vendor-specific O/R mappings from previous versions. This should help replace vendors and migrate applications.

Some other items related to persistence have also been standardized:

Object versioning for optimistic concurrency control

Database Key generation

Lazy and active loading of fields

Inherited

All this simplification paid a certain price. Due to the significant changes in the programming model, existing EJB 2.x applications will need to be rewritten to take advantage of the new JPA features. In addition, the new JPA specification does not include automatic maintenance of container management relationships (container-managed RELATIONSHIP,CMR). Relationship maintenance is now managed by the application.

OpenJPA Introduction

The Apache OpenJPA project is an Apache-licensed open source Java persistence API implementation. OpenJPA focuses on building a robust, high-performance, scalable JPA implementation.

Although the original source code was provided by bea® (through the acquisition of Solarmetric Kodo), other companies and individuals also participated in the OpenJPA project as volunteers, donors and users, including IBM. The OpenJPA community is booming and is expected to emerge from the incubation period sometime in the near future.

Thanks to the industry's interest in this OpenJPA project, this article will help explain how to leverage this implementation immediately in your WebSphere application Server environment.

Sample Application Research

For our example, we will use a customer order system, in which the customer creates an order, adds a product item, and then submits the order. Figure 1 illustrates the use cases in our sample system.

Figure 1. Sample application Use Cases

The activity diagram in Figure 2 illustrates the order in which those use cases are executed.

Figure 2. Sample application use case order

In this example, we focus on the persistence layer only, because our goal is to show how to use OpenJPA as a persistence layer in the WebSphere application Server V6.1.

Figure 3. Database Data Model

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.