Spring

    [Spring Boot & Elasticsearch] 복잡한 쿼리 요청 및 페이징 처리하기

    https://seovalue.github.io/2021/09/14/elasticsearch-paging/ Elasticsearch 복잡한 쿼리 요청 및 페이징 처리하기 - Milestone | Joanne Blog Spring Boot와 Elasticsearch를 활용해서 복잡한 쿼리를 요청해보자. 이 글은 배경과 삽질 기록을 담고 있으므로 매우 길다. 스압 주의 🚨 seovalue.github.io 블로그 이전 중입니다 :)

    [Spring boot] S3 이미지 업로드 시 cache-control 설정하기

    https://seovalue.github.io/2021/09/13/s3-cache-control/ S3 이미지 업로드 시 Cache-Control 설정하기 - Milestone | Joanne Blog Spring boot를 활용하여 S3에 이미지를 업로드 할 때, spring-cloud-starter-aws라는 의존성을 활용해서 이미지를 업로드할 수 있다. seovalue.github.io 블로그 이전 중입니다 :)

    트랜잭션과 @Transactional

    이 글은 망나니 개발자님의 [Spring] 트랜잭션에 대한 이해와 Spring이 제공하는 Transaction 핵심 기술을 읽고 정리한 글입니다. 트랜잭션이란? 트랜잭션은 더 이상 쪼갤 수 없는 작업의 최소 단위를 의미한다. 즉, 여러 작업을 진행하다가 문제가 생겼을 경우 롤백하기 위해 트랜잭션을 단위로서 사용할 수 있다. 트랜잭션에는 commit, rollback 두 가지의 경우가 존재한다. 모두 성공하여 commit 되거나, 하나라도 실패하면 rollback 되는 것이다. Spring에서 제공하는 Transaction 기능 Spring은 트랜잭션과 관련된 핵심 기술을 3가지 제공한다. 1. 트랜잭션 동기화 2. 트랜잭션 추상화 3. 트랜잭션 분리 1. 트랜잭션 동기화 개발자들이 JDBC의 모든 커넥션..

    @Controller와 @RestController의 요청부터 응답까지

    @Controller일 때의 요청부터 응답까지 동작 과정 @RestController의 요청부터 응답까지 동작 과정 RestController의 경우에는 Model에서 null을 반환하고, Model이 null인 경우에는 요청이 들어온 View를 그대로 사용한다. 참고 자료 https://mangkyu.tistory.com/m/49 https://wckhg89.github.io/archivers/understanding_jackson https://tecoble.techcourse.co.kr/post/2021-06-25-dispatcherservlet-part-1/ https://tecoble.techcourse.co.kr/post/2021-07-15-dispatcherservlet-part-2/

    [Spring Data JPA] 연관관계 편의 메서드

    연관관계 편의 메서드 양방향 연관관계를 맺을 때에는, 양쪽 모두 관계를 맺어주어야한다. 사실 JPA의 입장에서 보았을 때에는 외래키 관리자(연관관계의 주인) 쪽에만 관계를 맺어준다면 정상적으로 양 쪽 모두에서 조회가 가능하다. Team team1 = new Team("Team1", "민정팀"); em.persist(team1); Member member1 = new Member("Member1","민정"); member1.setTeam(team1); // 연관관계 설정 member1 -> team1 하지만 객체까지 고려한다면, 양쪽 다 관계를 맺어야한다. Team team1 = new Team("Team1", "민정팀"); em.persist(team1); Member member1 = new Membe..

    [Spring Data JPA] 영속성 관리

    이 글은 모두 자바 ORM 표준 JPA 프로그래밍 도서를 통해 학습하고 정리한 내용입니다. 엔티티 매니저 팩토리와 엔티티 매니저 엔티티 매니저 엔티티를 저장하고, 수정하고, 삭제하고, 조회하는 등 엔티티와 관련된 모든 일을 처리한다. (엔티티를 저장하는 가상의 데이터베이스라고 생각하면 이해하기 쉽다.) 데이터베이스 연결이 꼭 필요한 시점까지 커넥션을 얻지 않는다. 즉, 트랜잭션을 시작할 때 커넥션을 획득한다. 엔티티 매니저 팩토리 EntityManagerFactory emf = Persistence.createEntityManagerFactory("book"); 엔티티 매니저 팩토리(이하 엔매팩)는 엔티티 매니저를 만드는 공장이다. 공장을 만드는 비용은 매우 커서 애플리케이션 당 한개만 만들어서 공유하도..

    서비스에 @Transactional을 선언한 경우와 선언하지 않은 경우의 JPA save 동작

    서비스에 트랜잭션이 달린 경우 // postService.java @Transactional public void save() { repository.save(something); } 2021-08-22 15:54:08.656 DEBUG 9192 --- [ http-nio-8080-exec-1 ] o.s.o.j.JpaTransactionManager : Creating new transaction with name [me.elastic.application.PostService.save]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT 2021-08-22 15:54:08.657 DEBUG 9193 --- [ http-nio-8080-exec-1 ] o.h.e.t.i.Transact..

    Spring Data Elasticsearch 공식 문서에서 Repository 위주 정리

    8. Elasticsearch Repositories 원문: Spring Data Elasticsearch 해당 Document에서 예시로 들 Entity는 다음과 같다. @Document(indexName="books") class Book { @Id private String id; @Field(type = FieldType.text) private String name; @Field(type = FieldType.text) private String summary; @Field(type = FieldType.Integer) private Integer price; // getter ... } 8.1 Automatic creation of indices with the corresponding map..

    java.lang.NoClassDefFoundError: org/springframework/http/HttpHeaders 해결 방법

    dependency에 starter-web을 추가해주면 된다. implementation 'org.springframework.boot:spring-boot-starter-web' 참고 자료 https://stackoverflow.com/questions/62693959/spring-boot-2-3-1-elasticsearch-7-6-2