-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: delete-cascade a many-to-one relation
PostPosted: Tue Jun 15, 2004 9:47 am 
Newbie

Joined: Tue Jun 15, 2004 9:31 am
Posts: 4
Location: Frankfurt
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());
}
}


Top
 Profile  
 
 Post subject: It was an eclipse problem, sorry
PostPosted: Wed Jun 16, 2004 11:19 am 
Newbie

Joined: Tue Jun 15, 2004 9:31 am
Posts: 4
Location: Frankfurt
It has been solved, the code was correct, I just had to restart Tomcat and Eclipse completely.


Thanks anyway, Dirk


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.