我有以下休眠实体:
@Entity
@Table(name = "model_view")
public class ModelView {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "modelView_id")
private Integer id;
@ManyToOne
@NotNull
@JoinColumn(name = "page_id", nullable = false, insertable = true, updatable = true)
private Page page;
/* getters and setters */
}
和:
@Entity
public class Page {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "page_id")
private Integer id;
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
@JoinColumn(name = "page_id")
@IndexColumn(name = "modelView_id")
private Set<ModelView> modelViews = new HashSet<ModelView>();
/* getters and setters */
}
当我在 DAO 中删除实体 «ModelView» 时,出现异常:
ORA-01407: unable to replace ("MODEL_VIEW"."PAGE_ID") to NULL
怎么了?为什么休眠在删除之前将外键设置为NULL?