Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version: 3.1.3
Mapping documents:
Code:
<hibernate-mapping>
<class name="CustomerAddress"
schema="CUSTOMER"
table="CUSTOMER_ADDRESS"
optimistic-lock="version"
lazy="false">
<id name="oid" length="32">
<generator class="uuid.hex"/>
</id>
<version name="oversion"/>
<list
name="customerAddressKinds"
lazy="false"
cascade="all-delete-orphan">
<key>
<column
name="custo_addki_custo_addre"
index="ind_custo_addki_custo_addre"/>
</key>
<list-index
column="custo_addki_custo_addre_index"/>
<one-to-many
class="CustomerAddressKind"/>
</list>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():Code:
public Entity update(Entity entity) {
...
Session session = null;
try {
session = currentSession();
session.update(entity);
} finally {
safeCloseSession(session);
}
result = entity;
...
return result;
}
Name and version of the database you are using: Oracle 10
When I update my collection of "customerAddressKinds" after I have removed some customerAddressKind, the child record isn't deleted in the database. Only the foreign key is set to NULL. No other Objects reference the CustomerAddressKind.
I also tried to use the saveOrUpdate method, but is has the same output.
Does someone known why the cascade="all-delete-orphan" is not working like I expect? It should also delete the orphan record.
Thanks in advance!