어노테이션
@Component : 스프링이 run되는 시점 해당 클래스를 Bean으로 만들어서 IocContainer에 등록해준다.(RequireArgsConstructor를 이용해도 생성자 주입이 가능하다)
@Autowired : 이 메서드 혹은 필드에 주입 설정, 생성자가 하나일 땐 생략이 가능하다.
@Transaction : 모든 작업이 성공적으로 완료되어야 데이터베이스에 한꺼번에 적용해주는 기법인 Transaction적용.
테스트메서드에 사용시 테스트 종료시 자동으로 롤백된다.
@Component : 직접 작성한 Class를 Bean으로 등록할 수 있게 해주는 어노테이션
@Service : Service클래스에 사용
@Repository : Repository클래스에 사용
@Configuration : 해당 어노테이션을 적용한 클래스의 Method는 Bean에서 불러올 때 @Autowired상태로 불러올 수 있다.
@Require : setter method에 적용해주면 Bean 생성시 필수 프로퍼티 임을 알림.
@Entity : JPA가 컨트롤 할 수 있는 Entity클래스임을 지정해준다.
@Disable : 해당 Method는 실행하지 않는다.
@Table : 매핑할 테이블의 이름을 (name = "테이블 명")으로 지정해줄 수 있다.
@JsonInclude(JsonInclude.Include.NON_NULL) : 값을 반환할 때 Null이 아닌애들반 반환한다.
Entity 영속성 컨텍스트 컨트롤하기
[EntityManager].persist() : 저장
[EntityManager].find(찾고싶은 ClassType, 식별자pk) : 조회
[EntityManager].remove(entity) : 삭제
[EntituTransaction].detach(Entity) : 특정 Entity를 준영속 상태로 전환
[EntityManager].clear() : 내용만 비운 새로운 영속성틀 초기화
[EntityManager].close() : clear랑 다르게 완전 닫아버림. 다시 사용 불가
Insert Update Delete와 같이 데이터를 변경하는 SQL을 데이터베이스에 요청하기위해선 트랜잭션 환경이 필수.
위 사진은 Transaction환경이 선언 되어있지 않는데 persist(생성)을 시도하여 발생한 에러
내일부터 과제를 시도하기위해 오늘 하루는 하루종일 전력을 다 해 강의를 전부 완강했다.
힘들다. 오늘 쓸 것은 크게 많지 않았다. 다 모르는 것 투성이인데 어느부분을 모르는지 조차 헷갈리는 지경이다 일단 확실하게 모르는 부분 큰 틀을 잡는 것부터 해야겠다.