HomeAboutMeBlogGuest
© 2025 Sejin Cha. All rights reserved.
Built with Next.js, deployed on Vercel
🤩
개발
/
Spring Data
Spring Data
/
🧣
JPA(Java Persistence API)
/
SpringDataJPA 동작원리
SpringDataJPA 동작원리
SpringDataJPA 동작원리

SpringDataJPA 동작원리

동작 원리

Spring Data JPA는 어떻게 interface 만으로도 동작할까? (feat. reflection, proxy)
Dynamic Proxy와 Spring Data JPA
Dynamic Proxy 참고 : Spring AOP
  • JpaRepository를 extends하는 인터페이스를 만들어두면 Spring이 어플리케이션을 실행하면서 자동으로 해당 인터페이스를 구현하는 클래스를 동적으로 생성한 다음(SimpleJpaRepository) 스프링 빈으로 등록함
  • 그리고 해당 리포지토리를 실행하면 Dynamic Proxy가 SimpleJpaRepository를 타겟으로 갖게 하여 메서드를 실행해주게 됨

개요

  • 스프링에서 JPA를 편리하게 사용할 수 있도록 지원하는 프로젝트임
  • 데이터 소스 및 엔티티 매니저 트랜잭션 매니저 설정을 자동으로 해줌
    • 이전에는 configuration을 다 일일히 만들어주었어야 했는데
    • 🏎️
      JPA Configuration
spring: datasource: driver-class-name: org.h2.Driver url: jdbc:h2:~/order;DB_CLOSE_ON_EXIT=FALSE username: sa password: jpa: open-in-view: false hibernate: ddl-auto: create-drop show-sql: true properties: hibernate.format_sql: true