[
http://opensource.atlassian.com/projects/hibernate/browse/ANN-747?page=co...
]
Richard Bowers commented on ANN-747:
------------------------------------
I've hit exactly the same with a collection of enums. (I would hazard a guess that
primitives are also affected.)
Interestingly, adding the @OnDelete annotation to the collection does work for running
hbm2ddl, with the on delete cascade added to the tables produced. But as Nicole says,
Hibernate is not happy with this when the SessionFactory is created.
@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....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira