人を救おうとすると、人も都市も保存されません。 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
を見て、あなたのデータベースが – Cherif