I Upgraded from NHibenate 1.2 CR1 to 1.2 GA.
i'm using nhbibernate for mapping legacy things.
that's why i've to use assigned keys for some tables :-(
i'm using SAVE and Update as suggested,
so seems ok to me.
Since 1.2GA my nunit-tests fail when i create new entitys and attach
additional data to these entrys in the same session.
Things worked fine in 1.2 CR1 and all versions before since (0.8.0)
i think nhibernate trys to persist my data twice now.
Now i get 'Unexpected row count: 2; expected: 1' exception during commit...
Maybe there's a need now, to save bofore attaching aditional data ?
But i also might be a general trouble with asigned keys now, that's why i want to know if i'm doing something wrong.
(i also removed unsaved-value="null" which i had before in key-mapping, but didn't solve anything)
Would be great to hear any new ideas...
i tryed to 'reduce the problem as far as possible'
greetings
helmut
Hibernate version:
1.2.GA
Mapping documents:
Code:
<class name="MyClass" table="my_tab">
<id name="Id" column="MyId" type="String">
<generator class="assigned"/>
</id>
...
<set name="ExtraData" table="my_extra_tab" cascade="delete" lazy="false">
<key column="ClassId"></key>
<composite-element class="blabla">
....
</set>
Code between sessionFactory.openSession() and session.close():Code:
MyClass oCls = new MyClass();
oCls.Id = "testId1";
...
// we want to have additiona data imediately too...
oCls.ExtraData.Add(new ExtraData(blabla,,..));
...
m_tx = session.BeginTransaction();
session.Save(oCls); // Save for new instances
m_tx.Commit(); // Here the exception is thrown...
Full stack trace of any exception that occurs:Code:
....
NHibernate.Impl.SessionImpl.Execute(:0) NHibernate.Impl.SessionImpl.Execute(:0) [(null)] - could not synchronize database state with session
NHibernate.AdoNet.TooManyRowsAffectedException: Unexpected row count: 2; expected: 1
....
Name and version of the database you are using:mssql2005 in 2000 compatibility mode
The generated SQL (show_sql=true):Debug level Hibernate log excerpt:Problems with Session and transaction handling?
Read this:
http://hibernate.org/42.html[/code]