[
http://opensource.atlassian.com/projects/hibernate/browse/HHH-2368?page=c...
]
Rob Hasselbaum commented on HHH-2368:
-------------------------------------
I have read the documentation. Where does it say this is not supported?
Bulk delete fails when entity has a collection of composite-elements
--------------------------------------------------------------------
Key: HHH-2368
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-2368
Project: Hibernate3
Type: Bug
Components: core
Versions: 3.2.1
Environment: Hibernate 3.2.1, Oracle 10g
Reporter: Rob Hasselbaum
If an entity is mapped with a set of components ("composite-elements"), bulk
delete of the entity fails with a foreign key constraint violation because Hibernate does
not delete the contents of the child table. For example, suppose we have two POJOs:
public class Person {
private Long m_id;
private Set m_aliases = new HashSet();
.. getters and setters not shown ...
}
public class Name {
private String m_lastName;
.. getter and setter not shown ...
}
And the entity is mapped as follows:
<class name="Person" table="tbl_person">
<id name='id' column='objid'>
<generator class='native'/>
</id>
<set name="aliases" table="tbl_name_aliases"
lazy="false" cascade="all,delete-orphan">
<key column="person_id"/>
<composite-element class="Name" >
<property name="lastName" column="last_name"/>
</composite-element>
</set>
</class>
The following code generates an integrity constraint violation:
Session sess = getSessionFactory().getCurrentSession();
Person person = new Person();
Name name = new Name();
name.setLastName("Smith");
person.getAliases().add(name);
sess.saveOrUpdate(person);
sess.flush();
sess.createQuery("delete from Person").executeUpdate(); // FAILS!
--
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