-->
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.  [ 4 posts ] 
Author Message
 Post subject: Cascade="save-update, delete" for single table
PostPosted: Sun Mar 13, 2016 6:52 am 
Newbie

Joined: Sun Feb 28, 2016 3:16 pm
Posts: 17
Is it possible to delete cascade="save-update, delete" for single table by parent ID
(my current solution does not delete children)?
If yes, how?
Code:
     <class name="com.domain.project.models.Category" table="Category">
        <id name="id" type="long" access="property">
            <column name="categoryId" length="20"/>
            <generator class="native"/>
        </id>
        <property name="name" column="categoryName" type="string"/>
        <property name="parentId" column="categoryParentId" type="long"/>
        <bag name="children" table="Category" cascade="save-update, delete" inverse="true" lazy="true"
             fetch="select">
            <key>
                <column name="categoryParentId" not-null="true"/>
            </key>
            <one-to-many class="com.domain.project.models.Category"/>
        </bag>
    </class>


Top
 Profile  
 
 Post subject: Re: Cascade="save-update, delete" for single table
PostPosted: Sun Mar 13, 2016 8:43 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
Make sure you synchronize both ends of the association.


Top
 Profile  
 
 Post subject: Re: Cascade="save-update, delete" for single table
PostPosted: Sun Mar 13, 2016 6:22 pm 
Newbie

Joined: Sun Feb 28, 2016 3:16 pm
Posts: 17
Thank you!
I added
Code:
       <many-to-one name="parent" column="categoryParentId" class="com.electronic.commerce.models.Category"
            cascade="all"/>
instead of categoryOarentId.
But that did not helped yet.
I need to do something, but do not know, what.
Big number of topics are about simple relations, can not understood them for my case.
Mentioned mapping with new fix does not insert categoryParentId values in the table.


Top
 Profile  
 
 Post subject: Re: Cascade="save-update, delete" for single table
PostPosted: Mon Mar 14, 2016 1:53 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
For many-to-one associations, cascading does not have much sense because it would imply that you propagate the cascade operation from the child to parent.
Usually, cascading goes from parent to child entities.


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