현재 강의에서 em.persist 를 하는 이유가 정확하게 뭔가요?
681
작성한 질문수 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
63
1
리뉴얼 시기
0
132
2
변경감지(더티체킹) 이후 플러시할 경우의 쿼리
0
99
1
단일 테이블 시 null 값과 연관관계 필요성 질문
0
91
1
벌크연산에서 member.getAge 호출 시 영속성 컨텍스트에서 데이터를 가져오는건가요?
0
125
2
inheritance startegy 선택시 고려사항
0
90
1
Entity 동등성 비교
0
83
1
실무 조언 관련 질문입니다.
0
114
1
H2데이터베이스 파일 생성
0
128
2
서브쿼리 강의에서 ALL 예시 관련 질문드립니다.
1
121
2
수정또는 삭제시 영속성 엔티티에 값이 무조건 있어야 하나요?
0
105
1
JPQL 메소드와 락
0
107
1
Delivery @OneToOne
0
113
1
17강 4~5분대 테이블 값 조회가 안됩니다.
0
188
2
UnsupportedOperationException 발생
0
203
3
H2 Database 연결이 안됩니다.
0
154
2
연관관계 매핑 질문드립니다.
0
151
2
h2데이터베이스 실행오류
0
165
2
persistence.xml
0
205
2
양방향 연관관계에서 연관관계의 주인(mappedBy)을 왜 꼭 정해야 하나요?
0
146
1
영속성 컨텍스트
0
121
1
JPA 프록시
0
159
1
Native Query와 MyBatis
0
140
1
영속성 컨텍스트는 어떤 메모리에 저장되는건가요?
0
149
1





