현재 강의에서 em.persist 를 하는 이유가 정확하게 뭔가요?
673
작성한 질문수 13
안녕하세요
강의를 들으면서 잘 모르겠는 부분이 있습니다. em.persist 를 하는 것인데요
해당 메소드는 이제 영속성 컨텍스트에 추가를 하기 위한 것으로 있는 것인가요?
다른 이유는 없나 궁금합니다.
답변 1
2
안녕하세요. 김주현님, 공식 서포터즈 OMG입니다.
알고 계신대로 persist()는 엔티티 매니저를 사용해서 엔티티를 영속성 컨텍스트에 저장합니다.
public interface EntityManager {
/**
* Make an instance managed and persistent.
* @param entity entity instance
* @throws EntityExistsException if the entity already exists.
* (If the entity already exists, the <code>EntityExistsException</code> may
* be thrown when the persist operation is invoked, or the
* <code>EntityExistsException</code> or another <code>PersistenceException</code> may be
* thrown at flush or commit time.)
* @throws IllegalArgumentException if the instance is not an
* entity
* @throws TransactionRequiredException if there is no transaction when
* invoked on a container-managed entity manager of that is of type
* <code>PersistenceContextType.TRANSACTION</code>
*/
public void persist(Object entity);
감사합니다.
리뉴얼 시기
0
81
2
변경감지(더티체킹) 이후 플러시할 경우의 쿼리
0
76
1
단일 테이블 시 null 값과 연관관계 필요성 질문
0
70
1
벌크연산에서 member.getAge 호출 시 영속성 컨텍스트에서 데이터를 가져오는건가요?
0
105
2
inheritance startegy 선택시 고려사항
0
76
1
Entity 동등성 비교
0
70
1
실무 조언 관련 질문입니다.
0
100
1
H2데이터베이스 파일 생성
0
113
2
서브쿼리 강의에서 ALL 예시 관련 질문드립니다.
1
102
2
수정또는 삭제시 영속성 엔티티에 값이 무조건 있어야 하나요?
0
87
1
JPQL 메소드와 락
0
88
1
Delivery @OneToOne
0
104
1
17강 4~5분대 테이블 값 조회가 안됩니다.
0
154
2
UnsupportedOperationException 발생
0
168
3
H2 Database 연결이 안됩니다.
0
135
2
연관관계 매핑 질문드립니다.
0
131
2
h2데이터베이스 실행오류
0
148
2
persistence.xml
0
160
2
양방향 연관관계에서 연관관계의 주인(mappedBy)을 왜 꼭 정해야 하나요?
0
125
1
영속성 컨텍스트
0
104
1
JPA 프록시
0
141
1
Native Query와 MyBatis
0
117
1
영속성 컨텍스트는 어떤 메모리에 저장되는건가요?
0
130
1
임베디드 타입 예시 코드 관련 질문
0
173
3





