JPA DATA

    Mysql 과 JpaData를 활용하여 만든 BoardService

    1. build gradle plugins { id 'java' id 'org.springframework.boot' version '2.7.7' id 'io.spring.dependency-management' version '1.0.15.RELEASE' } group = 'com.example' version = '0.0.1-SNAPSHOT' sourceCompatibility = '11' configurations { compileOnly { extendsFrom annotationProcessor } } repositories { mavenCentral() } dependencies { implementation 'org.springframework.boot:spring-boot-starter-v..

    Entity 올바른 수정은 무엇인가 ?

    변경 감지(Dirty Checking 방식) 스프링에서 EntityManger의 주요 기능 중 하나로 Dirty Check가 있다. EntityManger는 현재 트랜잭션에서 영속성 컨텍스트에 포함되어 있는 Entity객체에 수정이 발생할 경우, 트랜잭션이 커밋되는 시점에 내부적으로 UPDATE 쿼리를 생성하여 전달한다. 기본적으로 EntityManager의 find()나 createQuery() 메서드를 통해 조회는 Entity 객체는 영속성 컨텍스트에 포함된다. 따라서, persist() 메서드를 명시적으로 호출하지 않아도 된다. 그러나, EntityManager는 준영속 상태(Detached)의 Entity에 대해서는 Dirty Check를 수행하지 않는다. 만약, 사용자가 폼 정보를 기반으로 새로..