The goal is to remove all Dependent when their Owner is deleted. I have the following classes:
@Entity
class Dependent {
@ManyToOne(cascade = CascadeType.PERSIST, fetch = FetchType.LAZY, optional = false)
@Column(name = "OWNER")
private Owner _owner;
}
@Entity
class Owner {
...
}
In the current implementation Dependent still exist after its Owner has been deleted.
Owner doesn't have any links to Dependent and can't be changed, so I can't use @Dependent annotation or cascade=DELETE.
Does JPA support such "inverse dependency"? Another question is what does optional="false" guarantee while the field _owner is being deleted?