반응형 전체 글82 JPA 활용 1 dependencies { implementation 'org.springframework.boot:spring-boot-starter-data-jpa' implementation 'org.springframework.boot:spring-boot-starter-thymeleaf' implementation 'org.springframework.boot:spring-boot-starter-web' compileOnly 'org.projectlombok:lombok' runtimeOnly 'com.h2database:h2' annotationProcessor 'org.projectlombok:lombok' testImplementation 'org.springframework.boot:spring-boot.. 2021. 4. 23. JPA 활용 2 API 개발 @Valid + (@NotEmpty와 같이 사용하여 유효성체크) //스프링 부트 2.3.0 이상 버전에서는 implementation 'org.springframework.boot:spring-boot-starter-validation' @RequestParam : 요청 파라미터를 1:1로 받아옴. @RequestParam을 붙여주면 필수적으로 값을 넘겨줘야한다.(required 값을 false로 바꿔주면 넘겨주지않아도 됨), 요청 파라미터랑 메서드 파라미터 이름이 같은 경우 생략 가능 @RequestBody : http 요청 body를 객체로 변환시켜준다. body가 존재하지 않는 get방식에는 사용불가하며 post방식과 함께 사용된다. json이나 xml 형태의 데이터를 message c.. 2021. 4. 23. 자바 ORM 표준 JPA 소개 코드 간편화 + 쿼리 X 관계형DB 중요 -> SQL 중심적인 개발 (객체 SQL), 단순 SQL의 반복 객체와 DB 차이로 인한 SQL매핑작업이 힘듦 -> Collection에 넣는다고 생각하면 편하다(JPA) 객체 -> DB : Insert 객체 JDBC Batch사용가능, Update/Delete -> row lock 방지 지연 로딩 : 객체가 실제 사용될 떄 쿼리 실행 즉시 로딩 : Join SQL로 한번에 연관 객체 미리 조회 설정 /resources/META-INF/persistence.xml 구동방식 EntityManagerFactory enf = Persistence.createEntityManagerFactory("hello"); EntityManager em = enf.create.. 2021. 4. 16. 스프링-입문-스프링부트 + JPA 인프런 스프링-입문-스프링부트(김영한) 을 듣고 정리한 내용 dispatcherservlet -> controller 검색 후 view resolver(template엔진사용)에게 -> 없으면 resource 검색 -> 반환 브라우저 어플리케이션 MessageConverter, JsonConverter, StringConverter @Service @Repository 사용안하고 @Configuration + @Bean으로 빈등록하면 -> 추후에 인터페이스로 클래스 바꾸기 쉽다 통합테스트시 DB데이터 비우기 위해 @Transactional 이용 (@Commit으로 저장할 수 있음) JDBC -> JdbcTemplate -> JPA -> Spring-Data-JPA JPA는 기술명세서 Hibernate는 .. 2021. 4. 16. 이전 1 ··· 9 10 11 12 13 14 15 ··· 21 다음 728x90 반응형