I posted this on the hibernate forums but thought I might as well ask
here in case someone has already encountered this. Basically, given
the below ... why does my composite-element always do an insert when
it should simply issue an update
Mapping:
HasMany<TrainingActivityCost>(x => x.ActivityCosts)
.WithTableName("TrainingActivityCosts")
.WithKeyColumn("TrainingActivityID")
.Cascade.All()
.Component(ac =>
{
ac.Map(a => a.ID).FormulaIs
("TrainingActivityCostID");
ac.Map(a => a.Comments, "Comments");
ac.Map(a => a.EntryDate, "EntryDate");
ac.Map(a => a.Number, "Number");
ac.Map(a => a.Actual, "Actual");
ac.Map(a => a.Estimate, "Estimate");
ac.References(a => a.CostType,
"TrainingCostTypeID").SetAttribute("not-null", "true");
})
.AsBag();
Modification:
var tc = activity.ActivityCosts.First(c => c.ID == Int32.Parse
(TrainingActivityCostID));
tc.Estimate = 4;
tc.Comments = "test";
When the data is persisted I always get a new record in my
TrainingActivityCosts table ... instead of the existing record being
updated.
Can anyone explain this behavior? Is this just how composite-elements
work? Is there a way to modify the mapping code to prevent it?
Thanks much - wg
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---