hi,
Im new to Nhibernate and Fluent Nhibernate so it might just be my
total luck of understanding, but im having some trouble with
cascading
im just trying to get two entity working for now.
what im trying to do is to get it so that when EntityA is Deleted, all
children EntityB are deleted to. but when you delete EntityB, Entity A
does not get deleted.
(im not sure what im doing wrong for this to cause so much trouble)
EntityA has children of EntityB (one to many releationship)
EntityA { int Id {get;set;} IList<EntityB> EntityBs {get;set;} }
EntityA { int Id {get;set;} EntityA EntityA {get;set;} }
EntityAMappings : ClassMap<EntityA>
{
Id(x => x.Id).Not.Nullable().GeneratedBy.Identity();
HasMany(x => x.EntityBs ).Cascade.All();
}
EntityBMappings: ClassMap<EntityB>
{
Id(x => x.Id).Not.Nullable().GeneratedBy.Identity();
References(x => x.EntityA ).Not.Nullable().Cascade.SaveUpdate();
}
to me this configuration makes sense
- when a new EntityA is saved, updated or deleted, entity B will be
saved/updated/deleted
- when a new EntityB is saved, updated, entityA will be saved/
updated. when EntityB is deleted, EnttiyA will not be. (im hoping this
is what it means)
In my deletion tests for entityA mappings, when i delete EntityA, all
child EntityB are deleted.
but in my deletion tests for EntityB mappings, EntityB gets deleted,
and so does EntityA. which is not what i want.
Issues 2 (this is probably releated):
in my deleting test i
I have a unsaved EntityB with a unsaved EntityA parent.
i insert the enttyB which automatically inserts EntityA
I then deleted entityB (which is deleting entityA issues 1 above)
I then use ISession.CreateCriteria(typeof (EntityB)) to load all the
EntityBs int he database and i get the following error... deleted
object would be re-saved by cascade
how do i tell nhibernate to ignore these entities after there are
deleted?
Am i expected to go through all the entity and remove the deleted
entities from the object graph manually?
Thank youin advance for any help you can give
Rhys
--
You received this message because you are subscribed to the Google Groups
"Fluent NHibernate" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/fluent-nhibernate?hl=en.