I have 2 classes: Entry and Content.
public class Entry implements Serializable {
@OneToOne(cascade=CascadeType.ALL)
private Content content;
}
And Content have his values (name etc etc etc) ... What I want to do is if a content its deleted I want to delete any Entry ho its related with ...
This its not the tipical orphan problem (Im not deleting an Entry! Im deleting the Content)
Entry can have or not a content related with ... and the contents existenc are independient of the entrys ...
How can I say to hibernate "Hey ... if u are going to delete a content find any related FK and delete it as well!"
Why not creating a link from Content to Entry as follows:
public class Content implements Seralizable {
@OneToOne(cascade=CascadeType.REMOVE, optional=true)
private Entry entry;
}
Please note the optional attribute. This represents the fact that a Content might not have an Entry related to it as you said in your post.