what is the difference between jpa and hibernate

来源:互联网 发布:手机吓人软件大全 编辑:程序博客网 时间:2024/05/29 13:15

maybe you have questions about JPA and Hibernate:such what is JPA ?what is Hibernate ? JPA and Hiberneate can bind together?

well,before we start it,we should understand  concept of   ORM , object relational mapping ,it is the process of mapping  objects to database tables  and vice versa.

JPA ,Java Persistene API is the specification which provides interface and annotation with the ORM  from managing relational database  in Java application .and there are several JPA  implementations, like Hibernate,IBatis ,Toplink ,EJB .

Hibernate,the ORM  implementation framework.success and acceptability of Hibernate framework has made it become the one of most popular persistent framework.

Hibernate can free developer from the database specific coding ,and focus more utilizing on powerful  oriented object design principles  to implement the core business logic.by using Hibernate you can switch databases rather easily and take advantage of the cache ,in terms of Hibernate second level cache and query cache.


you can annotate the Java domain objects ,but they will not work in running time .only add the implementation framework,such as Hibernate ,with you Hibernate implementation ,you can mange database in java application ,you can map ,query , update, delete to operate tables in Java application.because you use JPA to annotate domain objects ,JPA is framework independent  ,it is the specification .so if you want to replace Hibernate with another JPM implementation ,it is easy and smooth.

but when you straight use Hibernate without JPA ,it can not have extra features to replace with another ORM implementation ,you are already lock out inside.

from what have mentioned above, we can come to a  conclusion ,the best practices is using JPA and Hibernate together .