This code make always an update, even if i add a new record; if i change SaveOrUpdate to Save, all works (even updates)
in another solution with DB2/400 the same code (with SaveOrUpdate!)
works fine.
is it correct or not ? could be an oracle dialect bug?
thanks
regards
p.s : renamed namespace and class for readibility
Hibernate version: 1.2.0 beta 2
Mapping documents:
<?xml version='1.0' encoding='utf-8'?>
<hibernate-mapping xmlns='urn:nhibernate-mapping-2.2'>
<class name='MyNS.MyClass, MyNS' table='CC_TIPICTRL' lazy='false'>
<id name='ID' column='CCTCID'>
<generator class='assigned' />
</id>
<property name='Description' column='CCTCDESC' />
<property name='HasList' column='CCTCLISTA' />
<property name='HasValue' column='CCTCVALORE' />
<property name='IsContainer' column='CCTCCONTIENE' />
<property name='ControlClass' column='CCTCCLASSE' />
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
foreach (MyClass ctrl in dgvControls.DataSource as BindableList<MyClass>)
{
this.m_session.SaveOrUpdate(ctrl);
}
this.m_session.Flush();
Full stack trace of any exception that occurs:
in NHibernate.AdoNet.Expectations.BasicExpectation.VerifyOutcomeNonBatched(Int32 rowCount, IDbCommand statement) in C:\Documents and Settings\luke\Documenti\Riferimenti VS2005\NHibernate\NHibernate\AdoNet\Expectations.cs:riga 29
in NHibernate.Impl.NonBatchingBatcher.AddToBatch(IExpectation expectation) in C:\Documents and Settings\luke\Documenti\Riferimenti VS2005\NHibernate\NHibernate\Impl\NonBatchingBatcher.cs:riga 37
in NHibernate.Persister.Entity.AbstractEntityPersister.Update(Object id, Object[] fields, Object[] oldFields, Boolean[] includeProperty, Int32 j, Object oldVersion, Object obj, SqlCommandInfo sql, ISessionImplementor session) in C:\Documents and Settings\luke\Documenti\Riferimenti VS2005\NHibernate\NHibernate\Persister\Entity\AbstractEntityPersister.cs:riga 1848
in NHibernate.Persister.Entity.AbstractEntityPersister.Update(Object id, Object[] fields, Int32[] dirtyFields, Boolean hasDirtyCollection, Object[] oldFields, Object oldVersion, Object obj, ISessionImplementor session) in C:\Documents and Settings\luke\Documenti\Riferimenti VS2005\NHibernate\NHibernate\Persister\Entity\AbstractEntityPersister.cs:riga 1749
in NHibernate.Impl.ScheduledUpdate.Execute() in C:\Documents and Settings\luke\Documenti\Riferimenti VS2005\NHibernate\NHibernate\Impl\ScheduledUpdate.cs:riga 64
in NHibernate.Impl.SessionImpl.Execute(IExecutable executable) in C:\Documents and Settings\luke\Documenti\Riferimenti VS2005\NHibernate\NHibernate\Impl\SessionImpl.cs:riga 3299
in NHibernate.Impl.SessionImpl.ExecuteAll(IList list) in C:\Documents and Settings\luke\Documenti\Riferimenti VS2005\NHibernate\NHibernate\Impl\SessionImpl.cs:riga 3278
in NHibernate.Impl.SessionImpl.Execute() in C:\Documents and Settings\luke\Documenti\Riferimenti VS2005\NHibernate\NHibernate\Impl\SessionImpl.cs:riga 3230
in NHibernate.Impl.SessionImpl.Flush() in C:\Documents and Settings\luke\Documenti\Riferimenti VS2005\NHibernate\NHibernate\Impl\SessionImpl.cs:riga 3066
in CartellaClinica.Admin.frmControls.kbSave_Click(Object sender, EventArgs e) in C:\Documents and Settings\luke\Documenti\Visual Studio 2005\Projects\CartellaClinica\CartellaClinica.Admin\frmControls.cs:riga 60
Name and version of the database you are using: Oracle 10g
Debug level Hibernate log excerpt:
2006-12-04 12:10:11,736 [10] DEBUG NHibernate.Impl.SessionImpl - executing flush
2006-12-04 12:10:11,752 [10] DEBUG NHibernate.Persister.Entity.AbstractEntityPersister - Updating entity: [CartellaClinica.Domain.ClinicalFolderControlType#xxxxx]
2006-12-04 12:10:11,752 [10] DEBUG NHibernate.Impl.BatcherImpl - Opened new IDbCommand, open IDbCommands: 1
2006-12-04 12:10:11,752 [10] DEBUG NHibernate.Impl.BatcherImpl - Building an IDbCommand object for the SqlString: UPDATE CC_TIPICTRL SET CCTCDESC = ?, CCTCLISTA = ?, CCTCVALORE = ?, CCTCCONTIENE = ?, CCTCCLASSE = ? WHERE CCTCID = ?
2006-12-04 12:10:11,752 [10] DEBUG NHibernate.Persister.Entity.AbstractEntityPersister - Dehydrating entity: [CartellaClinica.Domain.ClinicalFolderControlType#xxxxx]
2006-12-04 12:10:11,752 [10] DEBUG NHibernate.Type.StringType - binding 'xxx' to parameter: 0
2006-12-04 12:10:11,752 [10] DEBUG NHibernate.Type.ByteType - binding '1' to parameter: 1
2006-12-04 12:10:11,752 [10] DEBUG NHibernate.Type.ByteType - binding '0' to parameter: 2
2006-12-04 12:10:11,752 [10] DEBUG NHibernate.Type.ByteType - binding '1' to parameter: 3
2006-12-04 12:10:11,752 [10] DEBUG NHibernate.Type.StringType - binding 'zzzzzzz' to parameter: 4
2006-12-04 12:10:11,752 [10] DEBUG NHibernate.Type.StringType - binding 'xxxxx' to parameter: 5
2006-12-04 12:10:11,752 [10] DEBUG NHibernate.SQL - UPDATE CC_TIPICTRL SET CCTCDESC = :p0, CCTCLISTA = :p1, CCTCVALORE = :p2, CCTCCONTIENE = :p3, CCTCCLASSE = :p4 WHERE CCTCID = :p5; :p0 = 'xxx', :p1 = '1', :p2 = '0', :p3 = '1', :p4 = 'zzzzzzz', :p5 = 'xxxxx'
2006-12-04 12:10:11,783 [10] DEBUG NHibernate.Impl.BatcherImpl - Closed IDbCommand, open IDbCommands: 0
2006-12-04 12:10:11,815 [10] ERROR NHibernate.Impl.SessionImpl - could not synchronize database state with session
NHibernate.StaleStateException: Unexpected row count: 0; expected: 1
in NHibernate.AdoNet.Expectations.BasicExpectation.VerifyOutcomeNonBatched(Int32 rowCount, IDbCommand statement) in C:\Documents and Settings\luke\Documenti\Riferimenti VS2005\NHibernate\NHibernate\AdoNet\Expectations.cs:riga 29
in NHibernate.Impl.NonBatchingBatcher.AddToBatch(IExpectation expectation) in C:\Documents and Settings\luke\Documenti\Riferimenti VS2005\NHibernate\NHibernate\Impl\NonBatchingBatcher.cs:riga 37
in NHibernate.Persister.Entity.AbstractEntityPersister.Update(Object id, Object[] fields, Object[] oldFields, Boolean[] includeProperty, Int32 j, Object oldVersion, Object obj, SqlCommandInfo sql, ISessionImplementor session) in C:\Documents and Settings\luke\Documenti\Riferimenti VS2005\NHibernate\NHibernate\Persister\Entity\AbstractEntityPersister.cs:riga 1848
in NHibernate.Persister.Entity.AbstractEntityPersister.Update(Object id, Object[] fields, Int32[] dirtyFields, Boolean hasDirtyCollection, Object[] oldFields, Object oldVersion, Object obj, ISessionImplementor session) in C:\Documents and Settings\luke\Documenti\Riferimenti VS2005\NHibernate\NHibernate\Persister\Entity\AbstractEntityPersister.cs:riga 1749
in NHibernate.Impl.ScheduledUpdate.Execute() in C:\Documents and Settings\luke\Documenti\Riferimenti VS2005\NHibernate\NHibernate\Impl\ScheduledUpdate.cs:riga 64
in NHibernate.Impl.SessionImpl.Execute(IExecutable executable) in C:\Documents and Settings\luke\Documenti\Riferimenti VS2005\NHibernate\NHibernate\Impl\SessionImpl.cs:riga 3299
in NHibernate.Impl.SessionImpl.ExecuteAll(IList list) in C:\Documents and Settings\luke\Documenti\Riferimenti VS2005\NHibernate\NHibernate\Impl\SessionImpl.cs:riga 3278
in NHibernate.Impl.SessionImpl.Execute() in C:\Documents and Settings\luke\Documenti\Riferimenti VS2005\NHibernate\NHibernate\Impl\SessionImpl.cs:riga 3221
|