Developing Web applications using the Java Persistence API and JavaServer Faces

Source: Internet
Author: User

When you need application support data, the Java™persistence API (JPA) provides a simple way to use a relational database. While JPA has been used with Enterprise Java™beans (EJBs) in the past, JPA is also handy to use directly with WEB applications. This article describes the simplified program models and tools provided by Ibm®rational®applicationdeveloper for Websphere®software V7.5, which make it easy to build WEB applications that use JPA. Note: This article is based on the IBM Rational application Developer V7.5 Open Beta release.

Learn how to use IBM Rational application through the sister article "using the Jpa,ajax and Dojo tools in IBM Rational application Developer V7.5 to develop WEB 2.0 applications" Developer the JPA, Ajax, and Dojo tools in V7.5 to create an end-to-end Web application.

You can also view product demos: Using JPA support in IBM Rational application Developer V7.5, this presentation will introduce one of the new features of IBM Rational application Developer V7.5 Support for the Java Persistence API (JPA, Java Persistence APIs).

The Java™persistence API (JPA) is a specification that is supported by Java model objects that use relational databases. This article gives you an overview of JPA and shows you how it works in a WEB application environment and how to use the Rational application Developer V7.5 application Java™server Faces (JSF) to build JPA WEB application.

Overview of JPA

JPA is a simplified program model for object-relational mapping and data support. Data support ensures that applications that retrieve data and update data are saved at the same time in the current state of the backend database. In the past, this was done through the use of Java Database connectivity (JDBC) APIs with other data frameworks, which are often cumbersome and involve writing complex query statements to add or modify data.

JPA simplifies this process by using your database tables, the Java representatives of the entities being accessed, and by providing a series of APIs to support and query data.

Entity

Entity objects are the main models used in JPA applications. An entity is the POJO (Plain old Java Object) that is modeled in the database for a table. It contains attributes that correspond to table columns and allows applications to be directly associated with the conceptual model of the database.

Example

This is a database that contains the Deptname column named Department. In the application, there is a corresponding Java class named Department, plus a zone name named Deptname, and the correct get and set methods. Figure 1 shows the entire Department table, along with the corresponding entity classes. Figure 1. Department Tables and Entities

Mapping information about an entity and relational databases, such as identifying key keywords and relationships, can be specified directly in an entity class using Java annotations. You can also choose to specify these mappings in a separate mapping configuration file. JPA uses the general default values for these data mappings wherever possible. This eliminates a large number of error codes and cumbersome mapping information in your application. For example, suppose that an entity class named Department is mapped to a database table named Department. You do not need to use annotations or configuration files to define the mapping in detail unless you need to change the default values.

Related Article

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.