아파트 관리 소프트웨어를 사용하고 있는데 문제가 있습니다.jpa 최대 절전 모드 일대일 업데이트
@Entity
public class Tenant extends AbstractEntity { //AbstractEntity contains the id
@Column(nullable = false)
private int number;
@OneToOne
private Apartment apartment;
}
및
@Entity
public class Apartment extends AbstractEntity { //AbstractEntity contains the id
@Column(nullable = false)
private int number;
@OneToOne
private Tenant tenant;
}
을하지만
EntityManager em = emProvider.get();
em.getTransaction().begin();
em.merge(apartment);
em.flush();
em.getTransaction().commit();
을 수행 할 때 그것은 단지 아파트에 입주를 저장하지만, 내가 좋아하는 것 :
내가 가지고있는 두 기관이 아파트를 임차인으로 갱신하십시오.
정말 임차인에게 아파트 필드를 설정해야합니까, 아니면 간단하게 해결할 수있는 방법이 있습니까? 감사
진심으로, Baskwo
https://en.wikibooks.org/wiki/Java_Persistence/Relationships#Cascading –