I "guess" this would happen if I try to update an entity without changes?
Actually I am updating two entities and it could also be because of saving
the parent first. I am updating both records so both should have already
been created. 2x update in other words. Since I'm still awaiting NHibernate
in Action I'll ask here :)
The following code fails some of the times with the exception from the
subject.

*Persistence code:*
_session.SaveOrUpdate(child);
_session.SaveOrUpdate(child.Parent);

_session.Transaction.Commit();

*The exception:*
NHibernate.StaleStateException: Batch update returned unexpected row count
from update; actual row count: 0; expected: 2735
at NHibernate.AdoNet.Expectations.VerifyOutcomeBatched(Int32
expectedRowCount, Int32 rowCount)
at NHibernate.AdoNet.SqlClientBatchingBatcher.DoExecuteBatch(IDbCommand ps)

at NHibernate.AdoNet.AbstractBatcher.ExecuteBatchWithTiming(IDbCommand ps)

at NHibernate.AdoNet.SqlClientBatchingBatcher.AddToBatch(IExpectation
expectation)
at NHibernate.Persister.Entity.AbstractEntityPersister.Update(Object id,
Object[] fields, Object[] oldFields, Object rowId, Boolean[]
includeProperty, Int32 j, Object oldVersion, Object obj, SqlCommandInfo sql,
ISessionImplementor session)
at NHibernate.Persister.Entity.AbstractEntityPersister.UpdateOrInsert(Object
id, Object[] fields, Object[] oldFields, Object rowId, Boolean[]
includeProperty, Int32 j, Object oldVersion, Object obj, SqlCommandInfo sql,
ISessionImplementor session)
at NHibernate.Persister.Entity.AbstractEntityPersister.Update(Object id,
Object[] fields, Int32[] dirtyFields, Boolean hasDirtyCollection, Object[]
oldFields, Object oldVersion, Object obj, Object rowId, ISessionImplementor
session)
at NHibernate.Action.EntityUpdateAction.Execute()
at NHibernate.Engine.ActionQueue.Execute(IExecutable executable)
at NHibernate.Engine.ActionQueue.ExecuteActions(IList list)
at NHibernate.Engine.ActionQueue.ExecuteActions()
at
NHibernate.Event.Default.AbstractFlushingEventListener.PerformExecutions(IEventSource
session)
at NHibernate.Event.Default.DefaultFlushEventListener.OnFlush(FlushEvent
event)
at NHibernate.Impl.SessionImpl.Flush()
at NHibernate.Transaction.AdoTransaction.Commit()
at Company.Project.Data.Update(Child child)

*The mappings:*

public ParentMap()
{
    Table("parent_table");

    Id(x => x.Id)
        .GeneratedBy.Assigned()
        .Column("parent_id");

    // Map columns

    HasMany(x => x.Children)
        .Table("child_table")
        .KeyColumn("parent_id")
        .LazyLoad()
        .Cascade.Delete();
}
public ChildMap()
{
    Table("child_table");

    Id(x => x.Id)
        .Column("child_id");

    // Map columns

    References(x => x.Parent)
        .Column("parent_id")
        .Not.Nullable()
        .Cascade.None()
        .LazyLoad();

    HasMany(x => x.SomeClass)
        .KeyColumn("child_id")
        .Table("some_class_table")
        .Cascade.All()
        .LazyLoad();

    HasMany(x => x.SomeClass2)
        .KeyColumn("child_id")
        .Table("some_class_table2")
        .Cascade.All()
        .LazyLoad();
}

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to