1
当我试图救人时,它既不保存任何人也不保存任何城市。我不想保存或更新City对象。我只想更新/删除joinColumn。有没有办法做到这一点?如何定义没有级联的单向OneToMany JPA关系?
Person person = new Person();
person.setCities(...);
personDAO.save(person);
public class Person{
@OneToMany(fetch = FetchType.EAGER)
@JoinColumn(name = "city_id")
private List<City> cities;
}
public class City{
@Id
@Column(name = "city_id")
@GeneratedValue(generator = "system-uuid")
@GenericGenerator(name = "system-uuid", strategy = "org.hibernate.id.UUIDGenerator")
private String cityId;
}
看到这个答案http://stackoverflow.com/questions/10551485/hibernate-cascade-type – Cherif
和我想再次考虑EagerFetch如果你的数据库很大 – Cherif