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: cascade=delete and saving new parent with no children
PostPosted: Tue May 12, 2009 11:15 pm 
Newbie

Joined: Tue May 12, 2009 11:08 pm
Posts: 2
Hi,
I'm caught between two problems here...

1. In my mapping i have
Code:
<map name="routeDests" inverse="true" cascade="save-update, delete" >
      <key column="ROUTE_NO" />
      <index column="DEST_STN" type="String" />
      <one-to-many class="RTS.RtRouteDest, RTSRailTerminalSystem.Core" />
</map>


This enables me to successfully create a new parent with no children (and not get any errors).

But, as a result of omitting the 'delete-orphan', I am unable to delete a child from a parent using cascading.

So, if I change my mapping to the following:

Code:
<map name="routeDests" inverse="true" cascade="save-update, delete, delete-orphan" >
      <key column="ROUTE_NO" />
      <index column="DEST_STN" type="String" />
      <one-to-many class="RTS.RtRouteDest, RTSRailTerminalSystem.Core" />
</map>


Then I can successfully delete the child from the parent using cascading.

But, then I am unable to create a new parent with no children, because of the following error: 'no collection snapshot for orphan delete' (see the following page for more info on that bug: http://nhjira.koah.net/browse/NHMA-19).

So, can someone please help me to set up my mapping file up so that i can do BOTH of the above?
These being...
1. create a new parent with no children, and
2. delete a child from a parent using cascading.


Thanks in advance.


Top
 Profile  
 
 Post subject: Re: cascade=delete and saving new parent with no children
PostPosted: Tue May 12, 2009 11:33 pm 
Newbie

Joined: Tue May 12, 2009 11:08 pm
Posts: 2
Just for some further info...

I can get around this by leaving the mapping as:

Code:
<map name="routeDests" inverse="true" cascade="save-update, delete" >
      <key column="ROUTE_NO" />
      <index column="DEST_STN" type="String" />
      <one-to-many class="RTS.RtRouteDest, RTSRailTerminalSystem.Core" />
</map>


which at least allows a new parent to be created with no children.

Then, upon the delete of the child, instead of using cascading, I can just do
Code:
childmgr.delete(currentchild)

and that works fine.

Would this be the suggested work-around? Or, is there a better way of handling the cascading in this instance?

Thanks again


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.