[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-4626) OneToMany cascadeType.ALL change collection and merge - does not remove entities

Hardy Ferentschik (JIRA) noreply at atlassian.com
Tue Jun 29 10:47:09 EDT 2010


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-4626?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=37612#action_37612 ] 

Hardy Ferentschik commented on HHH-4626:
----------------------------------------

Seems to me you are just missing the {{orphanRemoval=true}} option on your {{@OneToMany}} association.

> OneToMany cascadeType.ALL  change collection and merge - does not remove entities
> ---------------------------------------------------------------------------------
>
>                 Key: HHH-4626
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4626
>             Project: Hibernate Core
>          Issue Type: Bug
>          Components: entity-manager
>    Affects Versions: 3.3.1
>         Environment: JBoss 5.1.0.GA,  FC 10, Java 1.6
>            Reporter: Dave
>            Assignee: Hardy Ferentschik
>             Fix For: 3.6
>
>
> public Class Foo {
> @OneToMany(fetch=FetchType.LAZY, cascade={CascadeType.ALL}, mappedBy="foo")
> public List<Bar> getBars() {
>  return bars;
> }
> }
> // aFoo is persited
> Foo aFoo = ...
> aFoo.getBars().remove(0);  // remove the first
> aFoo.getBars().add(aBar);  // add new one
> em.merge(aFoo);
> For cascade={CascadeType.ALL}, it works for creating/deleting aFoo. 
> For merge, the new aBar is created, but the bar that was removed from collection are not deleted from persistence.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list