Spring Boot Jpa 简明教程
Spring Boot JPA vs Hibernate
JPA
JPA 是一个规范,它指定如何通过 Java 对象和关系数据库来访问、管理和持久化信息/数据。它为 ORM(对象关系映射)提供了一种标准方法。
JPA is a specification which specifies how to access, manage and persist information/data between java objects and relational databases. It provides a standard approach for ORM, Object Relational Mapping.
Hibernate
Hibernate 是 JPA 的一种实现。它提供了一个轻量级框架,并且是最流行的 ORM 工具之一。
Hibernate is an implementation of JPA. It provides a lightweight framework and is one of the most popular ORM tool used.
JPA Vs Hibernate
下表总结了 JPA 和 Hibernate 之间的差异。
Following table summerises the differences between JPA and Hibernate.
Category |
JPA |
Hibernate |
Type |
JPA is a specification and defines the way to manage relational database data using java objects. |
Hibernate is an implementation of JPA. It is an ORM tool to persist java objects into the relational databases. |
Package |
JPA uses javax.persistence package. |
Hibernate uses org.hibernate package. |
Factory |
JPA uses EntityManagerFactory interface to get the entity manager to persist objects. |
Hibernate uses SessionFactory interface to create session object which is then used to persist objects. |
CRUD Operations |
JPA uses EntityManager interface to create/read/delete operation and maintains the persistence context. |
Hibernate uses Session interface to create/read/delete operation and maintains the persistence context. |
Language |
JPA uses JPQL (Java Persistence Query Language) as Object Oriented Query language for database operations. |
Hibernate uses HQL (Hibernate Query Language) as Object Oriented Query language for database operations. |