spring: // 스프링과 연결 될 DB 설정
datasource:
url: jdbc:h2:tcp://localhost/~/jpashop
username: sa
password:
driver-class-name: org.h2.Driver
jpa: // JPA 설정
hibernate: // 하이버네이트 구현체
ddl-auto: create
properties: // 하이버네이트 프로퍼티(설정)
hibernate:
# show_sql: true
format_sql: true
logging.level:
org.hibernate.SQL: debug
org.hibernate.type: trace
file:///Users/lagoon/Documents/%EB%B2%A4%EC%B2%98/learnWebApp/jpashop/build/reports/tests/test/index.html
JUnit의 역할인지 확실하지 않은데 에러 발생 시 index.html 파일로 에러 로그를 만들어 준다.
에러 로그를 각 클래스 별로 확인 가능한데 쭉 확인하다보니 잘 모르겠지만 눈에 띈게
Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set
이 에러는
같은 상황에서 뜬다고 하니 바로 DB 연결부터 확인 했더니 접속이 안됨
DB 서버가 끊겨있어서 발생한 에러였음, DB 서버 다시 연결하니 해결
2020-07-30 15:20:46.894 DEBUG 26551 --- [ Test worker] org.hibernate.SQL :
drop table member if exists
2020-07-30 15:20:46.898 DEBUG 26551 --- [ Test worker] org.hibernate.SQL :
drop sequence if exists hibernate_sequence
2020-07-30 15:20:46.902 DEBUG 26551 --- [ Test worker] org.hibernate.SQL : create sequence hibernate_sequence start with 1 increment by 1
2020-07-30 15:20:46.903 DEBUG 26551 --- [ Test worker] org.hibernate.SQL :
create table member (
id bigint not null,
username varchar(255),
primary key (id)
)
@Entity
@Getter @Setter
public class Member {
@Id @GeneratedValue
private Long id;
private String username;
}
2020-07-30 15:28:30.977 DEBUG 26583 --- [ Test worker] org.hibernate.SQL :
insert
into
member
(username, id)
values
(?, ?)
2020-07-30 15:28:30.979 TRACE 26583 --- [ Test worker] o.h.type.descriptor.sql.BasicBinder : binding parameter [1] as [VARCHAR] - [memberA]
2020-07-30 15:28:30.980 TRACE 26583 --- [ Test worker] o.h.type.descriptor.sql.BasicBinder : binding parameter [2] as [BIGINT] - [1]
member.setUsername("memberA");
Member findMember = memberRepository.find(savedId);
Assertions.assertThat(findMember).isEqualTo(member);
2020-07-30 15:38:45.080 DEBUG 26605 --- [ Test worker] org.hibernate.SQL :
insert
into
member
(username, id)
values
(?, ?)
staff 37M 7 30 15:46 jpashop-0.0.1-SNAPSHOT.jar
jar 파일 잘 만들어지고 잘 실행 됨
SQL 쿼리는 기본적으로 <?>로 뜸, 쿼리가 제대로 날아갔는지 남기기
values
(?, ?)
2020-07-31 18:56:08.365 TRACE 28160 --- [ Test worker] o.h.type.descriptor.sql.BasicBinder : binding parameter [1] as [VARCHAR] - [memberA]
2020-07-31 18:56:08.366 TRACE 28160 --- [ Test worker] o.h.type.descriptor.sql.BasicBinder : binding parameter [2] as [BIGINT] - [1]
2020-07-31 18:56:08.366 INFO 28160 --- [ Test worker] p6spy : #1596189368366 | took 0ms | statement | connection 4| url jdbc:h2:tcp://localhost/~/jpashop
insert into member (username, id) values (?, ?)
insert into member (username, id) values ('memberA', 1);