-->
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.  [ 3 posts ] 
Author Message
 Post subject: parent/child????
PostPosted: Mon Feb 23, 2004 5:24 am 
Beginner
Beginner

Joined: Fri Jan 23, 2004 5:08 am
Posts: 21
My tree structure behaves strange or does the parent/child really behave this way?Let say i had three records:

Media
- News
-- Sports News

When i try to delete News, its children must also be deleted. But what is happening is that even its parent are also deleted. (the whole nodes are deleted). Does a tree structure table in hibernate behave this way or am i missing something in my configuration?


Industry table

Industry
id,(primary key)
name,
industry_id_fk (foreign key)


Industry.java
public Industry{

Industry parent;
Set childer;

}


Industry.hbm.xml

<hibernate-mapping >
<class name="com.eon.cms.vo.Industry" table="industry">
<id name="id" type="long" unsaved-value="0">
<generator class="native"/>
</id>

<set name="children" inverse="true" lazy="false" cascade="save-update" order-by="industry_id_fk">
<key column="industry_id_fk"/>
<one-to-many class="com.eon.cms.vo.Industry" />
</set>
<many-to-one name="parent" column="industry_id_fk" cascade="all" class="com.eon.cms.vo.Industry"/>

<property name="name" length="50"/>
</class>
</hibernate-mapping>


* i've already tried to change the cascade in set (save-update| all | all-delete-orphan) but still the results are the same.

hibernate: 2.1.2 version
database: postgres


any help?

thanks.


raymond


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 23, 2004 10:54 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Code:
<many-to-one name="parent" column="industry_id_fk" cascade="all" class="com.eon.cms.vo.Industry"/>


Change to cascade="save-update" (or, more likely, cascade="none").


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 23, 2004 9:36 pm 
Beginner
Beginner

Joined: Fri Jan 23, 2004 5:08 am
Posts: 21
It works!

thanks Gavin!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.