├── .gitignore ├── README.md ├── img └── 1-1.png ├── pom.xml └── src └── main └── java └── Application.java /.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | */target/** 3 | !.mvn/wrapper/maven-wrapper.jar 4 | mvnw* 5 | .mvn/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /build/ 25 | /nbbuild/ 26 | /dist/ 27 | /nbdist/ 28 | /.nb-gradle/ -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 스프링 데이터 JPA 2 | > JPA(Java Persistence API)를 보다 쉽게 사용할 수 있도록 여러 기능을 제공하는 ​스프링 데이터 JPA​에 대해 학습합니다 3 | 4 | ## 왜 JPA를 학습해야 하는가? 5 | - 도메인 주도 개발이 가능합니다. 6 | - 애플리케이션의 코드가 SQL 데이터베이스 관련 코드에 잠식 당하는 것을 방지하고 도메인 기반의 프로그래밍으로 비즈니스 로직을 구현하는데 집중할 수 있습니다 7 | - 그리고 개발 생산성에 좋으며, 데이터베이스에 독립적인 프로그래밍이 가능하고, 타입 세이프한 쿼리 작성 그리고 Persistent Context가 제공하는 캐시 기능으로 성능 최적화까지 가능합니다 8 | 9 | > 이러한 여러 장점을 지닌 JPA의 한가지 단점. 높은 학습 비용. 이번 강좌가 그 학습 비용을 조금이라도 낮추는데 도움이 되길 바랍니다 10 | 11 | ## 학습 목표 12 | - ORM(Object-Relation Mapping)에 대해 이해합니다 13 | - JPA를 사용할 때 반드시 알아야 하는 특징을 이해합니다 14 | - 스프링 데이터 JPA의 구동 원리를 이해합니다 15 | - 스프링 데이터 JPA를 사용하여 다양한 방법으로 Repository를 구현할 수 있습니다 16 | - 스프링 데이터 JPA를 사용하여 다양한 방법으로 쿼리를 만들고 실행할 수 있습니다 17 | 18 | ## 학습 목차 19 | ### 핵심 개념 이해 20 | - 관계형 데이터베이스와 자바 21 | - ORM이 해결하려는 문제 (패러다임 불일치) 22 | - JPA의 특징 이해 23 | - 스프링 데이터 JPA 원리 이해 24 | - 스프링 데이터 JPA 활용 25 | 26 | ### 스프링 부트 연동 27 | - 리포지토리 28 | - 엔티티저장 29 | - 쿼리 30 | - 스토어드 프로시져 31 | - 트랜잭션 32 | - Auditing 33 | 34 | 35 | # 강좌 소개 36 | Application -> 스프링 데이터 JPA (-> JPA -> JDBC) -> Database 37 | 38 | -------------------------------------------------------------------------------- /img/1-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/freespringlecture/spring-data-jpa-study/a50c319698bce72d82fb4a78f64ccb1ee8249ae0/img/1-1.png -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | me.freelife 8 | chap1-jdbcsample 9 | 1.0-SNAPSHOT 10 | 11 | 12 | 13 | org.postgresql 14 | postgresql 15 | RELEASE 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /src/main/java/Application.java: -------------------------------------------------------------------------------- 1 | import java.sql.Connection; 2 | import java.sql.DriverManager; 3 | import java.sql.PreparedStatement; 4 | import java.sql.SQLException; 5 | 6 | public class Application { 7 | 8 | public static void main(String[] args) throws SQLException { 9 | String url = "jdbc:postgresql://localhost:5432/springboot"; 10 | String username = "freelife"; 11 | String password = "1879asdf"; 12 | 13 | try(Connection connection = DriverManager.getConnection(url, username, password)){ 14 | System.out.println("Connection created: "+ connection); 15 | String sql = "CREATE TABLE ACCOUNT (id int, username varchar(255), password varchar(255));"; 16 | sql = "INSERT INTO ACCOUNT VALUES(1, 'freelife', '1879asdf');"; 17 | try(PreparedStatement statement = connection.prepareStatement(sql)){ 18 | statement.execute(); 19 | } 20 | } 21 | } 22 | } 23 | --------------------------------------------------------------------------------