-->
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: Set FK to null instead of deleting row when removing assoc?
PostPosted: Fri Jul 08, 2005 3:29 pm 
Beginner
Beginner

Joined: Sun Jun 05, 2005 9:45 am
Posts: 27
I have sketched out the relationship details below. A volunteer has a collection of Opportunities. Being associated with this table means that they have volunteered for a position at an event.

When I remove the Opportunity from the Volunteers collection, Hibernate tries to delete the entire Opportunity row. Instead, I want Hibernate to set the "volunteer_id" column to NULL. How can this be done? I have put my current associations below.

Many thanks,

Joshua


Code:
               Volunteer
                   | 1
                   |
                   |
                  \|/ M                     
Event  1--->M  Opportunity  M<--->M  Position



OPPORTUNITY
-----------------------
id
version
event_id
volunteer_id
position_id



Code:
    /**
     * This mapping appears in the Volunteer class
     * @hibernate.set name="opportunities" inverse="false" lazy="false" cascade="save-update"
     * @hibernate.collection-key column="volunteer_id"
     * @hibernate.collection-one-to-many class="Opportunity"
     */




    /**
     * This mapping apprears in the Opportunity class
     * @hibernate.many-to-one name="volunteer" column="volunteer_id" class="Volunteer" not-null="false"  lazy="false" inverse="true"
     * @return Volunteer
     */


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jul 10, 2005 10:22 am 
Newbie

Joined: Sun Jul 10, 2005 10:17 am
Posts: 6
Unfortunately I've got the same problem, and I also have no clue how to get this thing done.
Any information is appreciated.

Hibernate Team: Is this even possible yet?

cheers scorp2025


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jul 10, 2005 12:19 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Quote:
When I remove the Opportunity from the Volunteers collection, Hibernate tries to delete the entire Opportunity row.


You are mistaken. This is certainly not how Hibernate behaves for a one-to-many association without orphan delete.


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.