-->
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: Can this children-parent deletion be done automatically?
PostPosted: Tue Feb 27, 2007 2:13 pm 
Newbie

Joined: Wed Feb 07, 2007 7:55 pm
Posts: 18
Here is a common use scenario of messaging:

A message must have at least one recipient. A message shall be deleted after the last one recipient of the message is removed. Is possible that can be done automatically thorough Hibernate configuration/mapping?

Hibernate version:
3.2
Mapping documents:
Code:
    <class name="Message" table="message">
        <id name="id">
            <generator class="sequence">
                <param name="sequence">bm_message_id_seq</param>
            </generator>
        </id>
        <many-to-one name="sender" column="sender_id" class="User"/>
      <set name="receivers" table="bm_message_receiver">
         <key column="message_id"/>
         <many-to-many column="receiver_id" class="User"/>
      </set>       
        <property name="tDate" column="tdate" type="calendar" update="false" not-null="true"/>
        <property name="content" type="string" column="content"/>
    </class>


Top
 Profile  
 
 Post subject: Re: Can this children-parent deletion be done automatically?
PostPosted: Wed Feb 28, 2007 12:36 am 
Newbie

Joined: Mon Feb 26, 2007 3:22 am
Posts: 2
hm0 wrote:
Here is a common use scenario of messaging:

A message must have at least one recipient. A message shall be deleted after the last one recipient of the message is removed. Is possible that can be done automatically thorough Hibernate configuration/mapping?

Hibernate version:
3.2
Mapping documents:
Code:
    <class name="Message" table="message">
        <id name="id">
            <generator class="sequence">
                <param name="sequence">bm_message_id_seq</param>
            </generator>
        </id>
        <many-to-one name="sender" column="sender_id" class="User"/>
      <set name="receivers" table="bm_message_receiver">
         <key column="message_id"/>
         <many-to-many column="receiver_id" class="User"/>
      </set>       
        <property name="tDate" column="tdate" type="calendar" update="false" not-null="true"/>
        <property name="content" type="string" column="content"/>
    </class>



Im not sure whether this will solve or not..
try using list with cascade instead of set...


Top
 Profile  
 
 Post subject: Re: Can this children-parent deletion be done automatically?
PostPosted: Wed Feb 28, 2007 1:39 am 
Newbie

Joined: Wed Feb 07, 2007 7:55 pm
Posts: 18
gosoft.hibernate wrote:
try using list with cascade instead of set...


I fail to see how this can be a solution. The difference between a list and a set is that whether a collection is ordered or not, or having any duplicate elements or not. The cascade mode setting only has an impact on the children when the parent is deleted or updated. The problem is about the other way around: deleting the last child will lead to delete its parent.


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.