例如,我有以下實體: 客房實體:JPA的mappedBy不與關係長期以實體
@Entity
public class Room extends Base {
@OneToMany(mappedBy = "room")
private List<Person> persons;
//getters and setters
}
和人身實體:
@Entity
public class Person extends Base {
@ManyToOne
private Room room;
private String name;
//getters and setters
}
如果我加人到房間的人名單然後堅持,房間被添加,但人不是。我想,足夠的是將mappedBy
參數添加到OneToMany
註釋,但是..我應該怎麼做呢?
哦,謝謝,夥計。 – Squeez