-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: How to delete many side objects in merge operation?
PostPosted: Thu Jun 11, 2009 12:11 pm 
Newbie

Joined: Fri May 30, 2008 10:37 am
Posts: 10
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.java

Code:
   @ManyToOne(fetch = FetchType.LAZY)
   @JoinColumn(name = "AUTHOR_ID")
   public Author getAuthor() {
      return this.author;
   }


Author.java
Code:
   @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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.