I\'m using JPA over Hibernate in my web-app. Here are two entities (only getters are shown):
class Child { private Parent parent; @ManyToOne(optional=false)
For JPA 2.0 you can set orphanRemoval=true of the @OneToMany
@OneToMany
For JPA 1.0, you should use hibernate-specific annotations. That is the @Cascade annotation (instead of the cascade attribute), with a value of
@Cascade
cascade
@Cascade({CascadeType.ALL, CascadeType.DELETE_ORPHAN})
Hibernate 3.5+ implement JPA 2.0