Hello All --

I believe I may have discovered a bug in the Session.Merge() method,
specifically in the overload that takes string 'entityName' and object
'obj'. This overload pertains to entity mode of dynamic-map, rather
than POCO. I'm posting here because I'd like some feedback as to
whether what I'm seeing is in fact a bug or just my misunderstanding.

The behavior I'm observing goes like this... I have an entity
persisted to the database. Let's say it's defined as follows:

  entity["Id"] = 1
  entity["Name"] = "foo"
  entity["Inserted"] = "2005/05/05"

Next I create a non-persisted entity that represents an updated
version of the aforementioned entity.

  editedEntity["Id"] = 1
  editedEntity["Name"] = "bar"

Notice that Id is set to 1, signifying that we are dealing with an
updated version of our persisted entity. Notice also that we have no
Inserted field on our edited entity. This is because we don't need to
update that field, for obvious reasons. So now I want to persist the
edited entity, and here's where the alleged bug is manifesting. If I
call...

  session.Save("Widget", editedEntity);

...the record in the database gets updated ('foo' becomes 'bar'), but
Inserted gets updated to NULL. Perhaps this could be considered a bug,
but in a way it makes sense -- I didn't supply a value, so NH provides
a null for that field. So I try being more explicit...

  var merged = session.Merge("Widget", editedEntity);
  session.Save("Widget", merged);

But here again, Inserted gets updated to NULL. When I call Merge() I
want the persisted values to take precedence for unset values in my
editedEntity, but clearly that doesn't happen. Any values unset in
editedEntity get set to NULL in the merged entity.

Is this a bug? I have a failing test that I'm happy to upload
somewhere, if that's useful. If this is a bug, I'd be happy to have a
go at creating a patch.


Thanks in advance,

--Stuart
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"nhusers" 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/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to