Jpa basics (1): Comprehensive Explanation and highlights JPA

Source: Internet
Author: User

What is JPA?

JPA (Java persistence API)Is a Java persistence specification officially proposed by Sun.It provides Java developers with an object/association ing tool to manage the relational data in Java applications. His appearance mainly aims to simplify the existing persistent development work and integrate the ORM technology, and end the current situation where hibernate, toplink, JDO, and other ORM frameworks work independently. It is worth noting that JPA is developed based on existing ORM frameworks such as Hibernate, toplink, and JDO. It has advantages such as ease of use and high scalability. From the current developmentCommunityIn response, JPA was greatly supported and praised, including the development teams of spring and ejb3.0. With a focus on the technology trend in the next few years, JPA should be easily achieved as the standardization integrator in the orm field.

 

The overall idea of JPA is basically the same as that of existing ORM frameworks such as Hibernate, toplink, and JDO. In general,JPAIt includes the following three technologies:

ORMIng metadata

JPA supports two types of metadata: XML and jdk5.0 annotations (which can also be translated as annotations). The metadata describes the ing between objects and tables, and the framework persistently stores object in database tables.

JavaPersistent API

It is used to operate object and perform crud operations. The framework completes all tasks for us in the background. developers canCode.

Query Language (jpql)

This is an important aspect of persistent operations. You can use an object-oriented rather than a database-oriented query language to query data to avoidProgramSQL statements are tightly coupled.

 

Tip:JPA is not a New ORM framework. It is only used to standardize existing ORM technologies. It cannot replace existing ORM frameworks such as Hibernate and toplink. On the contrary, when using JPA for development, we will still use these ORM frameworks, but the applications developed at this time do not depend on a persistence provider. Applications can run in any JPA environment without modifying the code, truly achieving low coupling and scalable programming.

 

 

Simply put, JPA is what hibernate does, and they play the same role. However, note that JPA is only a set of specifications, not a set of products. Hibernate is already a set of products. His appearance mainly aims to simplify the existing persistent development work and integrate the ORM technology, and end the current situation where hibernate, toplink, JDO, and other ORM frameworks work independently. The Hibernate we learned earlier actually faces the development of hibernate APIs. What are the disadvantages of hibernate API development? The bad thing is that we are closely coupled with the hibernate product. If we leave hibernate, we cannot use our applications in other ORM frameworks. So the emergence of JPA is to end the current situation of hibernate, toplink, JDO and other ORM frameworks. Simply put: If you use JPA to develop applications, your applications can be used in persistence products that implement JPA specifications (such as Hibernate, toplink, and JDO) JPA is an inevitable trend of future development. We will adopt ORM technology in the future. We will not be dealing with hibernate programming, but toplink programming, but JPA standard programming. That is to say, after a few years, your application will rarely program the hibernate API. Why? This is just like accessing a database. If we didn't use the JDBC technology before, we can only use the APIS provided by various database vendors to connect to each database, to access their databases, we no longer need to link the APIS provided by the database vendor to the database since we had JDBC, but directly use the JDBC specification, we can connect to various databases. Currently, the relationship between JPA and Hibernate and toplink is the same. Like JDBC, JPA provides a common bridge tool to access various ORM implementation products. Through the JPA technology, we only need to deal with its standard programming. The compiled applications can be applied to various persistence products (including Hibernate and toplink ), that is to say, the products you use at the underlying layer are no longer important to me.

 

Summary:JPA is a set of specifications, not a set of products, so such as Hibernate, toplink, and JDO are a set of products. If we say these productsProduct has implemented this JPA specification, so we can call them a JPA implementation product.

The main designer of JPA is hibernate. JPA is a specification rather than a product, while Hibernate is a product of ORM technology. JPA is a bit like JDBC. It provides a unified interface for various ORM technologies to facilitate application porting to different ORM technologies.

Low coupling has always been our goal in software design. With JPA, we can completely free our applications from hibernate..

 

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.