I have a parent (Rule) object with many children (RuleDependency) objects. I’m trying to delete same child objects removing from the Collection/List in the parent object Rule through invoking the Save in. I have a so similar code using mapping by XML that works perfectly (cascade="all-delete-orphan" lazy="false" inverse="true") with NHibernate, but with JPA God helps me.
Parent
Code:
@Entity
@Table(name = "RULE")
public class Rule extends BeanBase {
@OneToMany(mappedBy = "rule", cascade = CascadeType.ALL, targetEntity = RuleDependency.class)
// @OnDelete(action = OnDeleteAction.CASCADE) ALSO doesn’t work
private List<RuleDependency> dependencies;
CHILD Code:
@Entity
@Table(name = "RULE_DEPENDENCY")
public class RuleDependency extends BeanBase {
@ManyToOne()
@JoinColumn(name = "RULE_ID", referencedColumnName="ID", nullable = false)
private Rule rule;
[b]Hibernate version:3.2.6 annotation 3.3.1