-->
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: could not save by child, have to save by parent
PostPosted: Sun Jun 10, 2007 1:11 pm 
Beginner
Beginner

Joined: Thu May 17, 2007 2:41 pm
Posts: 48
I have a parent-child relationship using list. for what ever reason, I am not to save a new child directly. I have to add it to its parent, and save the parent instead. But now I have a case where the parent is null, and this trick doesn't work for that. So, I still need to fix it so that I can save by the child.

My hbm is as follows:

Parent:
<class name="Page" >
<id name="pageId" type="int" column="PAGEID" >
<generator class="native" />
</id>

<property name="agename" column="pagename" />

<list name="tables" cascade="all-delete-orphan" >
<key column="PAGEID" not-null="true"/>
<list-index column="tableIdx"/>
<one-to-many class="Table"/>
</list>

</class>

child:
<class name="Table" >
<id name="ableId" type="int" column="TABLEID" >
<generator class="native" />
</id>

<property name="tablename" column="TABLENAME"/>

<many-to-one name="page"
class="Page"
column="PAGEID"
not-null="false"
insert="false"
update="false"/>
</class>

when saving by child, I get
not-null property references a null or transient value: Table._tablesBackref

Is it obvious, what causes the error?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 11, 2007 12:13 am 
Senior
Senior

Joined: Sat Aug 19, 2006 6:31 pm
Posts: 139
This could be the reason.

<list name="tables" cascade="all-delete-orphan" >

"delete-orphan" kinda implies that a child is to be deleted when it doesn't have a parent. Try removing "delete-orphan" form the cascade and see if it makes a diff.

_________________
Don't forget to rate the reply if it helps..:)

Budyanto


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 13, 2007 1:45 am 
Beginner
Beginner

Joined: Thu May 17, 2007 2:41 pm
Posts: 48
The point is not that I care so much about save the child with a null parent. I want to know why I can not save the child directly when the parent is NOT null. Is this a known limitation of hibernte list?


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.