-->
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: Error while Deleting object
PostPosted: Mon Jul 19, 2010 12:59 am 
Newbie

Joined: Mon Jul 19, 2010 12:46 am
Posts: 2
Hi,
I am using Fluent NHibernate using C#.
I am trying to delete an object. But it gives me an error as "deleted object would be re-saved by cascade (remove deleted object from associations)"
My mapping is like this

public VMapping()
{
Id(x => x.Id, "VID");
HasMany(x => x.SeatMaps).KeyColumnNames.Add("VID").Inverse().Cascade.AllDeleteOrphan().Not.LazyLoad();
Component(x => x.Name, c => c.Map(y => y.Value, "VName"));
Map(x => x.Code, "ExtRefCode");
References(x => x.Region, "RegionId").Not.LazyLoad();
}

public VSMMapping()
{
Id(x => x.Id, "VSMId");
References(x => x.Venue, "VId").Not.LazyLoad();
HasMany(x => x.VSMSItems).
KeyColumnNames.Add("VSMId").
Inverse().
AsSet().
Cascade.AllDeleteOrphan();
Component(x => x.Name, c => c.Map(y => y.Value, "VSMName"));
Map(x => x.Description, "Description");
}

and my delete code is

session.Delete(venueSeatMap);

But when i change the mapping of VSMMapping() as

public VSMMapping()
{
Id(x => x.Id, "VSMId");
References(x => x.Venue, "VId");
HasMany(x => x.VSMSItems).
KeyColumnNames.Add("VSMId").
Inverse().
AsSet().
Cascade.AllDeleteOrphan();
Component(x => x.Name, c => c.Map(y => y.Value, "VSMName"));
Map(x => x.Description, "Description");
}

It works perfectly.
But I dont want to use LazyLoading.
Can anyone tell me Y is the Delete not working when not using lazyloading.
Is there any workaround for delete when not using lazyloading?

Any help is much appreciated.
Thanks

SVP


Top
 Profile  
 
 Post subject: Re: Error while Deleting object
PostPosted: Mon Jul 19, 2010 1:25 am 
Newbie

Joined: Mon Jul 19, 2010 12:46 am
Posts: 2
Got it fixed
Modified the mapping as

public VMapping()
{
Id(x => x.Id, "VID");
HasMany(x => x.SeatMaps).KeyColumnNames.Add("VID").Inverse().Cascade.AllDeleteOrphan();
Component(x => x.Name, c => c.Map(y => y.Value, "VName"));
Map(x => x.Code, "ExtRefCode");
References(x => x.Region, "RegionId").Not.LazyLoad();
}


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.