TheAlmighty wrote:
Here's my c# code
Code:
foreach (OrderItem orderItem in m_orderItems) {
m_order.AddOrderItem(orderItem);
}
m_orderService.Insert(m_order);
I'll try to find something with google, but I'm allready searching for 2 days.
Thanks.
Hi,
I had the same problem.
You use the assigned generator, and as is mentioned in nhibernate documentation :
"Due to its inherent nature, entities that use this generator cannot be saved via the ISession's SaveOrUpdate()
method. Instead you have to explicitly specify to NHibernate if the object should be saved or updated by calling
either the Save() or Update() method of the ISession."
I suppose you want to save your objects using parent object (in your situation : order.Save()). To check if nHibernate must perform an Update or a Save, it test the value of the Id, If is null perform Save otherwise Update. In your code, Id is always not null because is assigned before saving it then NHibernate perform always an update, but there is no row to update, this is the explanation of the error message : Unexpected row count: 0; expected: 1
To correct this, use generator native :
<generator class="native"/>
instead of assigned.
P.S. Sorry for my english, I am french and my english is bad.
Fabien