[jboss-user] [EJB 3.0] - Re: delete object from jointable

Wolfgang Knauf do-not-reply at jboss.com
Wed Nov 19 03:37:42 EST 2008


Hi,

you mean you want to remove the child from all buyers, but keep the child?

Then your code should be (last two lines are changed):
Vendor child = this.manager.getReference(Vendor.class, vendorid );
  | 
  | Collection listParents = child.getBuyers();
  | Iterator iteratorParents = listParents.iterator();
  | while (iteratorParents.hasNext() == true)
  | {
  |   Buyer parentForChild = iteratorParents.next();
  |   parentForChild.getVendors().remove(child);
  | }
  | 
  | //remove ALL buyers from child:
  | listParents.removeAll();
  | 
  | //Now SAVE the child:
  | this.manager.persist(child);

Hope this helps

Wolfgang

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4190397#4190397

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4190397



More information about the jboss-user mailing list