What is the difference between JPA and Hibernate? [shut down]

This article was translated from: What's the difference between JPA and Hibernate? [Closed]

I understand that JPA 2 is a specification and Hibernate is a tool for ORM. I know that JPA 2 is a specification and Hibernate is a tool for ORM . Also, I understand that Hibernate has more features than JPA 2. But from a practical point of view, what really is the difference? In addition, I learned that Hibernate has more features than JPA 2 . But from a practical point of view, what is the real difference?

I have experience using iBatis and now I'm trying to learn either Hibernate or JPA2. I have experience using iBatis and now I am trying to learn Hibernate or JPA2. I picked up Pro JPA2 book and it keeps referring to "JPA provider". I picked up Pro JPA2 book and always referred to "JPA provider". For example: For example:

If you think a feature should be standardized, you should speak up and request it from your JPA provider, if you think a feature should be standardized, you should yell and request it from your JPA provider

This confuses me so I have a few questions: This confuses me, so I have a few questions :

  • Using JPA2 alone can I fetch data from DB by simply annotating my POJO's I can use JPA2 alone to annotate POJO to get data from the database
  • Is JPA2 supposed to be used with a "JPA Provider" eg TopLink or Hibernate? Should JPA2 be used with "JPA Provider" such as TopLink or Hibernate? If so, then what's the benefit of using JPA2 + Hibernate as compared to JPA2 alone, or compared to Hibernate alone? If so, what are the benefits of using JPA2 + Hibernate compared to using JPA2 alone or Hibernate alone ?
  • Can you recommend a good practical JPA2 book. Can you recommend a good practical JPA2 book ? "Pro JPA2" seems more like a bible and reference on JPA2 (It doesn't get into Queries until the later half of the book). "Pro JPA2" seems more like a Bible and reference book about JPA2 (until this book) (The second half of the book only enters Queries). Is there a book that takes a problem / solution approach to JPA2? Is there a book that adopts a problem / solution approach to JPA2 ?

#1st Floor

Reference: https://stackoom.com/question/fSep/What is the difference between JPA and Hibernate-close


#2nd Floor

JPA is just a specification which needs concrete implementation. JPA is just a specification that needs concrete implementation . At The default the Oracle Implementation the Provide IS "EclipseLink" now. The Oracle provided default implementation is now "Eclipselink". (Toplink is donated by Oracle to Eclipse foundation to merge with eclipselink) (Toplink is donated by Oracle to the Eclipse Foundation to merge with eclipselink )

(Reference : http://www.oracle.com/technetwork/middleware/toplink/index-085257.html http://www.eclipse.org/org/press-release/20080317_Eclipselink.php ) (参考: http : //www.oracle.com/technetwork/middleware/toplink/index-085257.html http://www.eclipse.org/org/press-release/20080317_Eclipselink.php

Using Eclipselink, one can be sure that the code is portable to any implementation if need arises. Using Eclipselink can ensure that the code is portable to any implementation when needed. Hibernate is also a full JPA implementation + MORE (Sort of JPA Plus). Hibernate is also a complete JPA implementation + MORE (Sort of JPA Plus ). Hibernate is a super set of JPA with some extra Hibernate specific functionality. Hibernate is a super set of JPA with some extra Hibernate specific functionality . So app developed in Hibernate may not be compatible when switched to other implementation. Therefore, when switched to other implementations, applications developed by Hibernate may not be compatible. Still hibernate is choice of majority of developers as JPA implementation and widely used. The hibernate state is still the choice of most developers because JPA is implemented and widely used.

Another JPA implementation is OpenJPA (openjpa.apache.org) which is an extension of Kodo implementation. Another JPA implementation is OpenJPA (openjpa.apache.org), which is an extension of Kodo implementation .


#3rd floor

JPA is a Java API specification which describes the management of relational data in applications using Java Platform. JPA is a Java API specification that describes the management of relational data in applications using the Java platform. where as Hibernate is an ORM (Object Relational Mapping) library which follows JPA specification. Among them, Hibernate is an ORM (Object Relational Mapping) library that follows the JPA specification .

You can think JPA as a set of Rules which is implemented by Hibernate. You can think of JPA as a set of rules implemented by Hibernate .


#4th floor

JPA is a dancer, Hibernate is a dancer.


#5th Floor

Some things are too hard to understand without a historical perspective of the language and understanding of the JCP. If there is no historical perspective of the language and understanding of the JCP , some things will be difficult to understand.

Often there are third parties that develop packages that perform a function or fill a gap that are not part of the official JDK. Usually, there are packages developed by third parties that can perform certain functions or fill gaps, which is not the official JDK portion. For various reasons that function may become part of the Java JDK through the JCP (Java Community Process) For various reasons, this function may become part of the Java JDK through the JCP (Java Community Process) .

Hibernate (in 2003) provided a way to abstract SQL and allow developers to think more in terms of persisting objects (ORM). Hibernate (in 2003) provides a way to abstract SQL and allows developers to persist objects (ORM) ) For more thinking. You notify hibernate about your Entity objects and it automatically generates the strategy to persist them. You notify hibernate about your Entity objects and it will automatically generate a strategy to persist them . Hibernate provided an implementation to do this and the API to drive the implementation either through XML config or annotations. Hibernate provides an implementation for this purpose, and provides an API to drive the implementation through XML configuration or annotations.

The fundamental issue now is that your code becomes tightly coupled with a specific vendor (Hibernate) for what a lot of people thought should be more generic. The fundamental issue now is that your code is tightly integrated with a specific vendor (sleep) Together, many people think this should be more general. Hence the need for a generic persistence API. Therefore, a generic persistence API is needed.

Meanwhile, the JCP with a lot of input from Hibernate and other ORM tool vendors was developing JSR 220 (Java Specification Request) which resulted in JPA 1.0 (2006) and eventually JSR 317 which is JPA 2.0 (2009). Meanwhile, JCP is in Hibernate With the strong support of other ORM tool vendors, JSR 220 (Java Specification Request) is being developed, resulting in JPA 1.0 (2006) and eventually JSR 317, JPA 2.0 (2009). These are specifications of a generic Java Persistence API. These are specifications of a generic Java Persistence API . The API is provided in the JDK as a set of interfaces so that your classes can depend on the javax.persistence and not worry about the particular vendor that is doing the work of persisting your objects. JDK provides the API in the form of a set of interfaces , So your class can depend on javax.persistence without worrying about the specific vendor that is doing object persistence. This is only the API and not the implementation. This is only the API, not the implementation. Hibernate now becomes one of the many vendors that implement the JPA 2.0 specification. Hibernate now becomes one of many vendors that implement the JPA 2.0 specification . You can code toward JPA and pick whatever compliant ORM vendor suits your needs. You can code JPA and choose any compatible ORM supplier that suits your needs .

There are cases where Hibernate may give you features that are not codified in JPA. In some cases, Hibernate may provide you with features not written in JPA. In this case, you can choose to insert a Hibernate specific annotation directly in your class since JPA does not provide the interface to do that thing. In this case, you can choose to insert Hibernate-specific annotations directly in the class because JPA does not provide an interface to perform this operation.

Source: http://www.reddit.com/r/java/comments/16ovek/understanding_when_to_use_jpa_vs_hibernate/ Source: HTTP : //www.reddit.com/r/java/comments/16ovek/understanding_when_to_use_jpa_vs_hibernate/


#6th floor

JPA is just a specification. In market there are many vendors which implements JPA. JPA is just a specification. There are many vendors implementing JPA in the market. Different types of vendors implement JPA in different way. Different types of vendors implement JPA in different ways. so different types of vendors provide different functionality so choose proper vendor based on your requirements. Therefore, different types of vendors provide different functions, so please choose the appropriate vendor according to your requirements.

If you are using Hibernate or any other vendors instead of JPA than you can not easily move to hibernate to EclipseLink or OpenJPA to Hibernate. But If you using JPA than you just have to change provide in persistence XML file.So migration is easily possible in JPA. If you are using Hibernate or any other vendor instead of JPA, you cannot easily sleep it to EclipseLink or convert OpenJPA to Hibernate. But if you are using JPA, you only need to change the provision in the persistent XML file. JPA.

Published 0 original articles · praised 75 · 560,000 views +

Guess you like

Origin blog.csdn.net/w36680130/article/details/105509663