ORM

    [JPA] Spring Jpa Repository의 영속성 컨텍스트 동작방식

    개발을 하다보면 Root 도메인에 종속적인 Sub 도메인을 어떻게 처리할지 고민이 될 때가 있다. 예를 들면, 재생 목록의 음악들은 재생 목록이라는 Root 도메인에 종속적인 Sub 도메인 들이다. Delete And Insert 방식을 실행할 수도 있고, Update 방식을 사용할 수도 있다. 그러다보니 JPA를 사용했을때, 각 개발 방식이 어떻게 동작하는지 알고 싶어서 직접 엔티티를 생성하며 테스트 코드를 작성해 보았다. 코드는 모두 깃허브에 작성해두었다. private SimpleEntity create(String name) { SimpleEntity entity = SimpleEntity.builder() .name(name) .build(); return repository.save(entit..

    [JPA] Spring Data에서 save()와 saveAll()의 성능 차이

    https://www.baeldung.com/spring-data-save-saveall 해당 글은 위 링크를 번역한 글입니다. Overview Spring Data의 save와 saveAll의 성능 차이를 알아보자. Application Book.java @Entity public class Book { @Id @GeneratedValue(strategy = GenerationType.AUTO) private long id; private String title; private String author; // constructors, standard getters and setters } BookRepository.java public interface BookRepository extends JpaR..