The irony here is that I'm using Merge to try and recover from a
StaleObjectStateException!
I'm using of r4098 from the NHibernate trunk.
Here's the test case:
[Test]
public void Should_be_able_to_merge_stale_object()
{
var obj = new Location { Address = new Address("1", "1", "1",
"1") };
var id = Nh.InsertIntoDb(obj); //flushes and clears session
var session = Nh.CreateSession();
var staleObject = session.Get<Location>(id);
staleObject.Name = "Fabio";
session.Evict(staleObject);
using (var session2 = Nh.CreateSession()) {
var updatedObj = session2.Get<Location>(id);
updatedObj.Name = "Fabio Maula";
session2.Flush();
}
using (var session3 = Nh.CreateSession()) {
session3.Merge(staleObject);
session3.Flush(); //this throws an exception
}
}
Here's the mapping file:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
auto-import="false"
default-access="field.camelcase-underscore"
namespace="Eca.NHibernateRepositoryEg.DomainModel"
assembly="Eca.NHibernateRepositoryEg.DomainModel">
<class name="Location">
<id name="Id" column="LocationId">
<generator class="assigned"/>
</id>
<version name="ConcurrencyId" unsaved-value="-1"/>
<property name="Name"/>
<property name="Url"/>
<component name="Address" >
<property name="Line1" not-null="true"/>
<property name="Town" not-null="true"/>
<property name="County" not-null="true"/>
<property name="PostCode" not-null="true"/>
</component>
</class>
</hibernate-mapping>
Am I right to assume that merge should handle this situation? If what
do you think the problem is?
Thanks
Christian
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---