영속성 전이1 [JPA] 영속성 전이(CASCADE)와 고아 객체 제거 1. 영속성 전이 : CASCADE 특정 엔티티를 영속 상태로 만들 때 연관된 엔티티도 함께 영속 상태로 만든다. (1) 영속성 전이 : 저장 @Entity @Getter @Setter public class Parent { @Id @GeneratedValue private Long id; private String name; @OneToMany(mappedBy = "parent", cascade = CascadeType.PERSIST) private List childList = new ArrayList(); public void addChild(Child child) { childList.add(child); child.setParent(this); } } cascade = CascadeType.AL.. 2022. 1. 3. 이전 1 다음 반응형