[hibernate-issues] [Hibernate-JIRA] Commented: (ANN-747) @CollectionOfElements does not cascade on delete
Greg Woolsey (JIRA)
noreply at atlassian.com
Tue Jun 30 19:44:16 EDT 2009
[ http://opensource.atlassian.com/projects/hibernate/browse/ANN-747?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=33505#action_33505 ]
Greg Woolsey commented on ANN-747:
----------------------------------
And I see this also when the Collection is a Map<Embeddable, Entity> - a collection of entities! @Cascade should work for @CollectionOfElements on a collection of @Entity objects.
> @CollectionOfElements does not cascade on delete
> ------------------------------------------------
>
> Key: ANN-747
> URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-747
> Project: Hibernate Annotations
> Issue Type: Bug
> Affects Versions: 3.3.1.GA
> Environment: Hibernate 3.2.6 GA
> Database: H2 1.0.72
> Reporter: Nicole Rauch
>
> Consider the following constellation:
> @Embeddable
> public class Foo {
> // ...
> }
> @Entity
> public class Bar {
> @CollectionOfElements
> private Set<Foo> myFoos;
> // ...
> }
> When I persist a Bar object that contains some Foos, and when I later decide to delete the Bar object, I get a foreign key constraint violation error message because the Foo objects, which contain a reference to the Bar object that owns them, are not deleted automatically. I would expect the default behaviour to be "on delete cascade" because the Foo objects are embeddables, thus they cannot exist on their own without the Bar object that owns them. But there is no way to tell Hibernate to cascade:
> - the @OnDelete annotation is only allowed for OneToMany relations
> - the @Cascade annotation is being ignored
> - there is no "cascade" property for the CollectionOfElements
> So my question is: Why does the cascading not occur automatically, and how do I tell Hibernate to cascade anyways?
> Thanks a lot in advance,
> Nicole
--
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