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.  [ 1 post ] 
Author Message
 Post subject: Delete only reference to child
PostPosted: Mon May 10, 2010 12:41 am 
Newbie

Joined: Tue Sep 27, 2005 11:38 pm
Posts: 3
I'm running in to a bit of a problem where any attempt to delete just the reference to a child also deletes the child record.

My schema looks like this

Person

Organisation

OrganisationContacts : Person
OrgId
PersonId
Role


When removing an Organisation i want to only delete the record in OrgnaisationContacts, but not touch the Person record.

My Mapping looks like this

Code:
public OrganisationMap()
        {
             Table("Organsations");
              ....
HasMany<OrganisationContact>(x => x.Contacts)
                .Table("OrganisationContacts ")
                .KeyColumn("OrgId")
                .Not.Inverse()
                .Cascade.AllDeleteOrphan();
}

public class OrganisationContactMap : SubclassMap<OrganisationContact>
    {
        public OrganisationContactMap()
        {
            Table("OrganisationContacts");
   
            Map(x => x.Role, "PersonRole");
            Map(x => x.IsPrimary);
        }
    }




At the moment just removing a contact from the IList<Contact> either doesn't reflect in the database at all, or it issues two delete statements DELETE FROM OrganisationContact & DELETE FROM Person, or tries to set PersonId to null in the OrganisationContacts table. All of which are not desirable.

Any help would be great appreciated.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.