I have an 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.
The property Snapshot.Dirty after adding the detail is set to true.
Code:
//extract of lazy load method...
if (!NHibernateUtil.IsInitialized(nativeColl))
{
openSession();
_session.Lock(item, LockMode.None);
NHibernateUtil.Initialize(nativeColl);
closeSession();
}
I need a workaround to solve this problem, because this error is thrown in a wizard and I cannot save the Order before the user finish the operation.
Any idea?
Antonella
Hibernate version: 1.0.2
Full 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