# Hibernate는 JPA의 구현체이다
- JPA는 스팩이나 인터페이스를 뜻한다.
- Hibernate는 JPA의 구현체라고 보면 된다.
=> JPA만 가지고는 할 수 없고, 구현체가 필요하다.
=> JPA를 사용하기 위해 굳이 Hibernate를 사용할 필요는 없다.
ex) Hibernate, EclipseLink, DataNucleus ...
- 밑에 예시와 같이 인터페이스를 직접 구현한 라이브러리이다.
List list = new ArrayList();
// | |
// Interface Implementation
- Java-persistence-api
<dependency>
<groupId>javax.persistence</groupId>
<artifactId>javax.persistence-api</artifactId>
<version>2.2</version>
</dependency>
- Hibernate-core
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.4.29.Final</version>
</dependency>
- 밑의 사진은 JPA와 Hibernate의 상속 및 구현 관계를 나타낸 것이다.
- JPA의 EntityManagerFactory, EntityManager, EntityTransaction에 대해서
Hibernate에서는 SessionFactory, Session, Transaction으로 상속받고 각각 Impl로 구현하고 있음을 확인할 수 있다.
사용하는 방법
CASE 1 : JPA + JPA Provider(Hibernate)
- 실제 구현체로 Hibernate를 사용
- 장점 : 다른 구현체로 쉽게 변경이 가능하다.
CASE 2 : only Hibernate
- JPA를 통하지 않고 바로 Hibernate를 사용
- 장점 : JPA를 포함하고 자체적인 기능이 있어 powerful하게 사용 할 수 있다.
참고자료
Hibernate ORM 5.4.33.Final User Guide
Fetching, essentially, is the process of grabbing data from the database and making it available to the application. Tuning how an application does fetching is one of the biggest factors in determining how an application will perform. Fetching too much dat
docs.jboss.org
'Backend > Spring & SpringBoot' 카테고리의 다른 글
[Spring Boot] Spring에서의 Hibernate 사용법 (0) | 2022.03.07 |
---|---|
[Spring Boot] Hibernate 에서 Entity Relationships (0) | 2022.03.07 |
[Spring Boot] Hibernate 의 동작 원리 및 특징과 사용 예시 (1) | 2022.03.05 |
[Spring Framework] 03_03. 요청 파라미터 처리 방법 (0) | 2020.08.18 |
[Spring Framework] 03_02. GET / POST 요청 메서드 매핑 (0) | 2020.08.18 |