h2 데이터베이스 사용
~/study/h2/bin의 h2.sh
- 순수 jdbc(무려 15년전)
참고만하고 넘어가자
2.jdbcTemplate
3.JPA
JPA는 기존의 반복 코드는 물론이고, 기본적인 SQL도 JPA가 직접 만들어서 실행
개발 생산성 up!!
JPA는 표준 인터베이스 (ORM) Object Relational Mapping
구현은 각 업체마다 다르다
gradle에
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'추가
application.properties
spring.datasource.url=jdbc:h2:tcp://localhost/~/test
spring.datasource.driver-class-name=org.h2.Driverspring.datasource.username=sa
spring.jpa.show-sql=truespring.jpa.hibernate.ddl-auto=none- entity 매핑 (@Entity)
@ID ==PK , @GeneratedValue == db에서 자동생성
@Column(name=“username”) == 컬럼명
jpa는 EntityManager로 모든게 동작함
스프링 데이터 JPA (JPA 업그레이드 버전)****