JPA Overview
JPA through JDK 5.0 annotations or XML description of the object - the relationship between the mapping table and run-time persistence of the entity object to the database.
Sun introduced the new JPA ORM specification for two reasons: First, simplify the existing Java EE and Java SE applications of the subject of a lasting development; second, Sun hopes the integration of ORM technology, the world is normalized.
JPA by the EJB 3.0 expert group software development, JSR-220 as part of the achievement. However, it is not limited to EJB 3.0, you can in Web applications, and even the use of desktop applications. JPA aims to provide persistence for POJO standards, we can see that the practice of the past few years to explore, be able to operate independently from the container to facilitate the development and testing of the idea of people. At present, Hibernate 3.2, TopLink 10.1.3 and OpenJPA provides the realization of the JPA.
JPA's overall thinking and existing Hibernate, TopLink, JDO and other ORM framework in line. In general, JPA includes the following 3 aspects of the technology:
ORM metadata mapping, JPA support for XML and the JDK 5.0 metadata annotations in two forms, metadata to describe objects and the mapping relations between the tables, the framework of which the entity object persistent to the database table;
JPA's API, the operating entity of the object used to implement the CRUD operations, the framework in the background for us to complete all the things developers from tedious JDBC and SQL code out.
Query language, this is a lasting operation of a very important aspect, and not for the adoption of object-oriented database query language to query the data, procedures to avoid tight coupling of SQL statements.
Third, JPA advantage
1 standardization
JPA is the JCP's Java EE organization one of the criteria, so any claim that the framework in line with the JPA standard has to follow the same structure, provide the same access to the API, which guarantees the JPA-based enterprise applications can be developed through a small number of modifications can be in different operation under the framework of the JPA.
Features two pairs of container-class support
JPA framework to support large data sets, services, concurrent services such as container class, which goes beyond a simple JPA persistence framework of the limitations of the application in the enterprise to play a greater role.
3 easy-to-use, integrated to facilitate
One of the main objectives of the JPA is to provide a simpler programming model: In the framework of the creation of JPA to create entities and as simple Java type, there is no binding and that it only need to use to carry out javax.persistence.Entity Notes; JPA framework and interface is very simple and not too many special rules and requirements of design patterns, developers can easily grasp. JPA based on the principle of non-invasive design, and can be easily integrated to other frameworks or containers.
4 comparable to query capabilities of JDBC
JPA query language is oriented rather than object-oriented database, which the natural object-oriented query syntax structure, can be regarded as equivalent of Hibernate HQL. JPA defines a unique JPQL (Java Persistence Query Language), JPQL is an extension of EJB QL, which is a query language entities, operation targeted entities, rather than the relational database table, and can support batch updates and modified, JOIN, GROUP BY, HAVING, etc. can usually only provided by SQL Advanced Search features, able to support even subquery.
5 to support the advanced features of object-oriented
JPA can support high-level object-oriented features, such as between the types of inheritance, polymorphism and type of the complex relationship between this kind of support enables developers to maximize the use of object-oriented model design of enterprise applications, rather than need to deal with these features in the relational database persistence.
Fourth, JPA suppliers
One of the objectives of JPA is to develop a lot of suppliers from the API, and developers can code to achieve the API, rather than the use of private providers specific API. Therefore developers can use the API suppliers to obtain specific JPA specification does not address the needs of the application functionality. As much as possible the use of JPA API, but when the need for providers in public but the specification did not provide the function, then the use of supplier-specific API.
1 Hibernate
JPA is necessary to achieve its Provider function, Hibernate is a JPA Provider in a very strong, the moment should be none. In terms of functionality, JPA is the Hibernate function is a subset. Hibernate from 3.2 onwards, began compatible JPA. Sun TCK was Hibernate3.2 the JPA (Java Persistence API) compatibility certification.
As long as familiar with the Hibernate or other ORM framework in the use of JPA will be found when in fact very easy to use. For example, the status of the target entity in Hibernate free, lasting and free the three, JPA, there are new, managed, detached, removed, Anyone who can see, we know that these are one-to-one of the state. Another example is flush method, are the corresponding, while others said Another example of the Query query = manager.createQuery (sql), it is the wording of Hibernate in session, and in the JPA has become a manager, so from Hibernate to JPA's price should be very small
Similarly, JDO, have begun to compatible JPA. In the field of ORM, JPA is a benevolent government, it seems, is the normative specification. In support of major manufacturers, JPA has become widely used.
2 Spring
Spring + Hibernate often referred to as the Java Web application framework for the most popular combinations. JCP adopted in the Web Beans JSR, but would like JSF + EJB + JPA, from JBoss Seam (Spring except for) a number of components and EJB 3 (the current basic block to provide dependency injection functionality and simplify the framework of Session Bean) combination of a standardized Web. Spring 2.0 now for the JPA to provide a complete EJB container contract that allows JPA in any environment can be managed in the Spring service layer to use (including Spring's AOP and DI all enhanced). At the same time, on the combination of a Web application is EJB, Spring + Hibernate or Spring + JPA debate has been filled in the ear.
Spring 2.0.1 in formally provide support JPA, which led to the development of JPA, it is necessary to know the benefits of JPA is to be separated from container operations, become more concise.
3 OpenJPA
OpenJPA is provided by Apache open source project, it implements the JPA in the EJB 3.0 standard, to provide for the development of powerful, easy-to-use framework for persistent data management. OpenJPA package of interactive and relational database operations, so that developers focus on business logic in the preparation. OpenJPA can be used as the persistence layer framework for an independent role to play, you can easily with other Java EE application framework or standards in line with the EJB 3.0 container integration.
4 other
Currently supports, including the realization of Toplink, Hibernate Entitymanager and so on. TopLink ago to charge for the open source now. OpenJPA Although free, but the functionality, performance, universal, and so more need to make greater efforts.
For the EJB, the entity Bean has been the subject of criticism, because of its too complicated and large. The emergence of JPA, the separation of a high degree of complexity. This allows EJB has become easier to promote.
In short, JPA specification only major concern is the behavior of the API, and the achievement of the completion of the majority by a wide variety of performance-related tuning. Nevertheless, the realization of all reliable data should have some sort of cache, as a choice. I hope the near future, JPA can become a true standard.
E. Summing Up
EJB 3.0 and JPA There is no doubt that Java EE 5 will be the main selling point. In some areas, they have brought to the Java community a competitive advantage, and in other areas of Java and its competitors, regardless of par (because, it is undeniable that the present does not yet exist in some areas, standards-based approach).
Over the past few years, Spring Framework has been the EJB in the enterprise field of major competitors. EJB3.0 specification to solve a lot of issues to promote the emergence of Spring. With the appearance of it, EJB3.0 There is no doubt better than the Spring to provide the development of experience - the most notable advantage is that it does not require configuration files.
JPA provides a standard OR mapping solution, the solution is fully integrated into EJB3. 0-compatible container. The JPA will continue the steady development of the older generation, but business applications will use the raw may be reduced. JPA compatible with the achievement of the entity manager is likely to be it seems that the direction of development of such technologies.
Java EE specification of a larger series of issues has nothing to do with JPA. Java EE Series specification issues related to Web and EJB containers integration between. Spring in this area still has a major competitive advantage. JBoss's Seam project attempts to use a custom approach to solve this problem. Caucho Resin Application Server attempts to expand the borders and containers in the Web container to support the use of @ EJB Notes. We hope that Java EE 5.1 will solve the problem of integration layer to provide us with a comprehensive and standards-dependent injection method.
In the near future, Sun may JPA as a separate JSR treated at the same time as the JPA may also be part of Java SE. But these are not important, it is important that we can now from the container in the case of Java SE applications in the use of the JPA.
JPA has been sustained as a target of the standards, not only can Java EE application server support, but also can be directly used in Java SE. Developers would not be required to the existing ORM framework of a wide range of difficult choices, according to Sun's anticipated that the existing ORM framework of the glory of his head will be dim gradually, no longer has the appeal of the past.
Tags: entity object (RSS), jpa (RSS), persistence (RSS), database table (RSS), jdbc (RSS), sql statements (RSS), web applications (RSS), jcp (RSS), database query language (RSS), annotations (RSS), run time (RSS), coupling (RSS), mapping table (RSS), desktop applications (RSS), expert group (RSS), object oriented database (RSS), standardization (RSS), group software development (RSS), very important aspect (RSS), second sun (RSS)
Permalink: http://www.codeweblog.com/jpa-overview/





















