I fixed it :)
The problem was still in here
public override string GetEntityName(object entity)
{
var type = entity.GetType();
if (entity is IProxyTargetAccessor)
type = type.BaseType;
//return type.Name; // problem
return type.FullName;
}
Now this passes and I am very pleased. I could use a piece of advice
regarding the session management being done.
I'll send you the new test and and a code revision for the sake of
completeness. Thanks for your help. It was nice to have someone to
talk it over with.
[Test]
public void Updating_state_trackable_entities_should_work2()
{
//use an NHibernate.IInterceptor in NHibernate
configuration whoose Instantate method returns proxies with injected
undo/redo functionality.
var mp = new
ManagerPool(Shared.StateManager.NHibernateHelper.Helper);
var compMan = mp.GetManager<CompanyManager>();
var comp = compMan.GetAll().First();
Assert.IsTrue(comp is IStateTrackable);
var statemanager = (comp as IStateTrackable).Originator;
comp.Address = "1313 Webfoot Walk, Duckburg, Calisota";
Assert.IsTrue(statemanager.CanUndo);
Assert.AreEqual(1, statemanager.ActionsCount);
var myComp = statemanager.Detach(comp);
Assert.AreSame(myComp, (comp as
IStateTrackable).ProxyTarget);
Assert.AreSame(typeof(Company), myComp.GetType());
Assert.IsFalse(statemanager.IsStateTrackable(myComp));
//fails - NHibernate.MappingException : a different object
with the same identifier value was already associated with the
session: f0bd989f-65a6-46ed-87de-4d466f38753a, of entity:
Indigo.Domain.Company
//compMan.SaveOrUpdate(myComp);
(mp as IDisposable).Dispose();
//use another session to save the object. if I don't
dispose the original session I get the 'Illegal attempt to associate a
collection with two open sessions' exception here.
var mp2 = new ManagerPool();
var compMan2 = mp2.GetManager<CompanyManager>();
compMan2.SaveOrUpdate(myComp);
}
--
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.