[
http://opensource.atlassian.com/projects/hibernate/browse/HHH-4301?page=c...
]
Lance Hankins commented on HHH-4301:
------------------------------------
Same issue here. We have tons of @ElementCollection uses in our codebase.
We had to resort to an after-the-fact SQL file which has to drop and recreate each of the
constraints generated for these @ElementCollection's (simply to append an "on
delete cascade" to the constraint). Yuck.
@CollectionOfElements does not cascade on delete
------------------------------------------------
Key: HHH-4301
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-4301
Project: Hibernate Core
Issue Type: Bug
Components: annotations
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....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira