I have a Order class with two one-to-many relations with lazy = "true".
I load an order, then I have:
//client code
order.Details1.Add(detail); //now the collection is dirty
order.Details2.Count --> throws HibernateException("reassociated object has dirty collection")
This happens when the LazyLoad method tries to attach the second collection to the order object. Tthe property Snapshot.Dirty after adding the detail is set to true.
//extract of lazy load method...
Code:
if (!NHibernateUtil.IsInitialized(nativeColl))
{
openSession();
_session.Lock(item, LockMode.None);
NHibernateUtil.Initialize(nativeColl);
closeSession();
}
Hibernate version: 1.0.2Full stack trace of any exception that occurs:
at NHibernate.Impl.OnLockVisitor.ProcessCollection(Object collection, PersistentCollectionType type)
at NHibernate.Impl.AbstractVisitor.ProcessValue(Object value, IType type)
at NHibernate.Impl.AbstractVisitor.ProcessValues(Object[] values, IType[] types)
at NHibernate.Impl.AbstractVisitor.Process(Object obj, IClassPersister persister)
at NHibernate.Impl.SessionImpl.Reassociate(Object obj, Object id, IClassPersister persister)
at NHibernate.Impl.SessionImpl.Lock(Object obj, LockMode lockMode)
at Persistence.Repository.ReconnectSession(ItemBase item, IList nativeColl) in D:\...\BackEnd\Repository\Repository.cs:line 469
Name and version of the database you are using:
SQL SERVER 2000
Code: