我在我的项目中使用休眠注释,我已经创建了表,这一切都很好,除了当我检查数据库时它们没有级联,即使我确保将它放在类中。这是我如何做的一个例子:
public class Item implements java.io.Serializable {
/**
*
*/
private static final long serialVersionUID = 8271695210797279161L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "IDitem", unique = true, nullable = false)
private int iditem;
@ManyToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
@JoinColumn(name = "IDDIVISION", nullable = false)
private Division division;
@Column(name = "SIGLE", length = 254)
private String sigleItem;
@Column(name = "DESCRIPTION", length = 254)
private String description;
....
}
我在所有 ManyToOne、OneToMany 和 ManyToMany 案例中都有 cascade = CascadeType.ALL。我也尝试添加
@OnDelete(action = OnDeleteAction.CASCADE)
@Cascade(org.hibernate.annotations.CascadeType.DELETE_ORPHAN)
就像这里提到的,但没有任何改变
你能帮我解决问题吗?谢谢你!