Hibernate version: 1.0.2
Code between sessionFactory.openSession() and session.close():
//USER INTERFACE
private void btnUpdateCross_Click(object sender, EventArgs e)
{
BizDomain.CentralModel.Test.Masters.LoadById(451);
ObjectModel.Test.Master master1 = BizDomain.CentralModel.Test.Masters[0];
ObjectModel.Test.Cross cross = master1.Crosses[0];
cross.Prop1 = "Prop prova test";
cross.Prop2 = "Prop 2";
BizDomain.CentralModel.Test.Masters.SaveOrUpdate();
}
public ItemBase SaveOrUpdate(ItemBase entity)
{
try
{
beginTransaction();
_session.SaveOrUpdate(entity);
commitTransaction();
}
catch (Exception ex)
{
rollbackTransaction();
..........
}
finally
{
disposeTransaction();
}
return entity;
}
Full stack trace of any exception that occurs:
Unable to insert duplicate key in object 'Test_Cross'.
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe)
at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
at NHibernate.Impl.BatcherImpl.ExecuteNonQuery(IDbCommand cmd)
at NHibernate.Impl.NonBatchingBatcher.AddToBatch(Int32 expectedRowCount)
at NHibernate.Persister.EntityPersister.Insert(Object id, Object[] fields, Boolean[] notNull, SqlString sql, Object obj, ISessionImplementor session)
Name and version of the database you are using:
MS SQL Server 2000
The generated SQL (show_sql=true):
NHibernate: INSERT INTO dbo.Test_Cross (UpdateTimestamp, CreateUser, UpdateUser, Guid, Prop1, Prop2, IdMaster1, IdMaster2) VALUES (@p0, @p1, @p2, @p3, @p4, @p5, @p6, @p7)
@p0 = '03/05/2006 17.13.44'
@p1 = '0'
@p2 = '0'
@p3 = '00000000-0000-0000-0000-000000000000'
@p4 = 'Prop prova test'
@p5 = 'Prop 2'
@p6 = '451'
@p7 = '2'
A first chance exception of type 'NHibernate.ADOException' occurred in NHibernate.dll
Thanks
Antonella
|