사용자 도구

사이트 도구


springframework:spring_data_jdbc

차이

문서의 선택한 두 판 사이의 차이를 보여줍니다.

차이 보기로 링크

양쪽 이전 판 이전 판
다음 판
이전 판
springframework:spring_data_jdbc [2022/01/21 22:29]
kwon37xi
springframework:spring_data_jdbc [2023/09/15 19:50]
kwon37xi
줄 1: 줄 1:
 ====== Spring Data JDBC ====== ====== Spring Data JDBC ======
   * [[https://projects.spring.io/spring-data-jdbc/|Spring Data JDBC]]   * [[https://projects.spring.io/spring-data-jdbc/|Spring Data JDBC]]
 +  * https://github.com/spring-projects/spring-data-jdbc
   * [[https://spring.io/blog/2018/09/17/introducing-spring-data-jdbc|Introducing Spring Data JDBC]]   * [[https://spring.io/blog/2018/09/17/introducing-spring-data-jdbc|Introducing Spring Data JDBC]]
 +  * [[springframework:spring_data_jdbc:querydsl|Spring Data JDBC & QueryDSL]]
  
 ===== 가장 큰 특징 ===== ===== 가장 큰 특징 =====
줄 39: 줄 41:
 ===== Eager Loading ===== ===== Eager Loading =====
   * [[https://docs.spring.io/spring-data/jdbc/docs/2.2.3/api/org/springframework/data/jdbc/core/mapping/AggregateReference.html|AggregateReference]] 로 매핑된 필드를 [[https://docs.spring.io/spring-data/jdbc/docs/2.2.3/api/org/springframework/data/relational/core/mapping/Embedded.html|@Embedded]]로 매핑한 View 객체를 생성하고 일반 SQL 쿼리로 join 을 통해 값을 채우면 된다.   * [[https://docs.spring.io/spring-data/jdbc/docs/2.2.3/api/org/springframework/data/jdbc/core/mapping/AggregateReference.html|AggregateReference]] 로 매핑된 필드를 [[https://docs.spring.io/spring-data/jdbc/docs/2.2.3/api/org/springframework/data/relational/core/mapping/Embedded.html|@Embedded]]로 매핑한 View 객체를 생성하고 일반 SQL 쿼리로 join 을 통해 값을 채우면 된다.
-  * +  * [[https://github.com/schauder/talk-beyond/blob/master/src/main/java/de/schauderhaft/beyond/join/MinionView.java|MinionView]] ''Minion''이라는 Entity에 대해 join 데이터를 ''Embed''한 view 클래스. 
 +  * 어차피 조회한 엔티티가 proxy가 아니라서 별다른 side effect 없이 View 객체 사용가능. 
 + 
 +<code java> 
 +class MinionView extends Minion { 
 +    MinionView(String name, AggregateReference<Person, Long> evilMaster) { 
 +        super(name, evilMaster); 
 +    } 
 + 
 +    @Embedded(onEmpty = Embedded.OnEmpty.USE_EMPTY, prefix = "master_"
 +    Person master; 
 +
 + 
 +// join 해서 MinionView에 값을 넣는 Repository 쿼리 
 +@Query("select m.id as id, m.name name, m.number_of_eyes as number_of_eyes, " + 
 +        "p.name as master_name, p.id as master_evil_master " + 
 +        "from minion m join person p on p.id = m.evil_master"
 +List<MinionView> allMinionViews(); 
 +</code> 
  
 ===== 참조 ===== ===== 참조 =====
줄 54: 줄 75:
     * https://github.com/schauder/talk-beyond : 관련 소스     * https://github.com/schauder/talk-beyond : 관련 소스
   * [[https://www.youtube.com/watch?v=SJlKBkZ2yAU|Spring Data JDBC: Beyond the Obvious - YouTube]]   * [[https://www.youtube.com/watch?v=SJlKBkZ2yAU|Spring Data JDBC: Beyond the Obvious - YouTube]]
 +  * [[https://luvstudy.tistory.com/174|Spring Data JDBC는 현재 쓸 만할까?]]
 +    * 2022현재 multiple datasource 지정 안됨
 +    * [[https://github.com/spring-projects/spring-data-relational/issues/544|Multiple datasources support [DATAJDBC-321] · Issue #544 · spring-projects/spring-data-relational]]
 +    * [[https://github.com/spring-projects/spring-data-relational/pull/1005|Add jdbcConverterRef to @EnableJdbcRepositories by kota65535 · Pull Request #1005 · spring-projects/spring-data-relational]]
 +    * [[https://youtube.com/playlist?list=PLbuI9mmWSoUFGL6B_NxB9IoGqyDq-vEen&si=aaNTrHZx_9fswpn6|Spring Dataa JDBC - SpringBoot 3]]
springframework/spring_data_jdbc.txt · 마지막으로 수정됨: 2023/09/15 19:50 저자 kwon37xi