| Hi there,
 I ran into a delete-cascading problem, then read the faqs, worked with some examples but still getting rid of it - so I decided to post a question in this forum, maybe somebody have had this problem before...
 
 I have a parent-child relation which does not delete the refering child database entries, and I really don't understand why nothing happens (Database is mySQL).
 
 Thanks a lot, Dirk
 
 
 ----- my mapping-file for the parent -----
 
 <hibernate-mapping>
 <class name="example.Parent" table="PARENT">
 <id name="parentId" column="parent_id" type="long">
 <generator class="increment"/>
 </id>
 <property name="parentName" column="parent_name" type="java.lang.String"/>
 <set name="childs" inverse="true" lazy="true" cascade="delete">
 <key column="parentId"/>
 <one-to-many class="example.Child"/>
 </set>
 </class>
 </hibernate-mapping>
 
 
 ----- my mapping-file for the child -----
 
 <hibernate-mapping>
 <class name="example.Child" table="CHILD">
 <id name="childId" column="child_id" type="long">
 <generator class="increment"/>
 </id>
 <property name="childName" column="child_name" type="java.lang.String"/>
 <many-to-one name="parent" class="example.Parent" column="parentId"/>
 </class>
 </hibernate-mapping>
 
 ----- the java-code to delete the parent -----
 
 public void removeParent(Long theParentId){
 try {
 Session session = SessionManager.currentSession();
 Transaction tx = session.beginTransaction();
 Parent theParent = (Parent) session.load(Parent.class, theParentId);
 session.delete(theParent);
 tx.commit();
 SessionManager.closeSession();
 } catch (HibernateException e) {
 throw new RuntimeException(e.getMessage());
 }
 }
 
 
 |