In My application I have one to meny relationshp between Author and Book classes.
Author 1---->* Book. I have done the mappping as follows;
Book.javaCode:
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "AUTHOR_ID")
public Author getAuthor() {
return this.author;
}
Author.javaCode:
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER, mappedBy = "author")
public Set<Book> getBooks() {
return this.books;
}
I am using merge operation for updating detached objects. When ever I am updating or adding Book objects and Merging the Author object, changes are reflected in the database. However when I client have remove Book object (Say in the database there are three books related to Author, But now I am caling merge operation with two Books objects with matching pk in the collection.
But I do not see missing Book object being deleted from the Book table. Can someone help me explaining how to do this. Is there any way to remove books (many side) without explicitly deleting those. i.e. By Merging Author object.
Thanks.