[jboss-user] [EJB 3.0] - deleting entities from a Collection

aberezin do-not-reply at jboss.com
Thu Sep 7 14:47:35 EDT 2006


Sorry if this is a bit of a repost.  I am trying to figure out the best way to remove enties from a OneToMany collection (either uni or bidirectional).

I have an entity Foo, that contains a OneToMany Set:
  Set getBars()

If I add new Bar objects to the set and call em.merge(myFoo), it properly persists the new Bar objects.  However, simply removing Bar objects from the set and calling em.merge(myFoo) does not remove the underlying Bar objects from the db.  It seems I have to explicitly call em.remove(myBar1), ...

Is this how thinks are suppose to work?  I could see in a ManyToMany that you could not delete the underlying row simply because it is no longer in the Set.  However, in a OneToMany, it would seem that the any Bar objects no longer in the set should be deleted.



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

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



More information about the jboss-user mailing list