Wednesday, August 23, 2006 5:28 PM
Arghhh, I am really starting to hate NHibernate List support. However, this is my problem and not NHibernate's. I just have to figure out how this is supposed to work.
I have a list collection
<list name="EmailNotifications"
table="Rules_Notifications"
access="nosetter.camelcase-underscore">
<key column="OrganizationId" />
<index column="Indexer" />
<composite-element class="Cystem.Notification,Cystem">
<property name="Email" type="String" />
<property name="Language" type="Cystem.LanguageType,Cystem" />
</composite-element>
</list>
However when I go to execute the following code I get an exception:
private void RemoveFromList(int index, IList list)
{
if(list.Count > index)
{
object o = list[index];
list.Remove(o);
}
}
//or
private void RemoveFromList(int index, IList list)
{
if(list.Count > index)
{
list.RemoveAt(index);
}
}
I get the following error:
NHibernate.HibernateException: SQL insert, update or delete failed (expected affected row count: 1, actual affected row count: 2). Possible causes: the row was modified or deleted by another user, or a trigger is reporting misleading row count.
at NHibernate.Impl.NonBatchingBatcher.AddToBatch(Int32 expectedRowCount)
at NHibernate.Collection.BasicCollectionPersister.DoUpdateRows(Object id, PersistentCollection collection, ISessionImplementor session)
at NHibernate.Collection.AbstractCollectionPersister.UpdateRows(PersistentCollection collection, Object id, ISessionImplementor session)
at NHibernate.Impl.ScheduledCollectionUpdate.Execute()
at NHibernate.Impl.SessionImpl.Execute(IExecutable executable)
at NHibernate.Impl.SessionImpl.ExecuteAll(IList list)
at NHibernate.Impl.SessionImpl.Execute()
at NHibernate.Impl.SessionImpl.Flush()
at NHibernate.Transaction.AdoTransaction.Commit()
Any thoughts?
Dru