如何在同一个实体类上做单向的一对多关系?
@Entity
public class User extends Model {
@Id
private Long id;
....
@OneToMany(cascade = CascadeType.PERSIST)
@JoinTable(name="ignores",
joinColumns = @JoinColumn(name = "user_id"),
inverseJoinColumns = @JoinColumn(name="ignored_id"))
public List<User> ignoreList;
....
}
[PersistenceException:插入具有单向关系的 bean [class models.User] 时出错。对于插入,您必须在主 bean [class models.User] 上使用级联保存。]