Hello,
I'm new with NHibernate and I just tried to walk thru the Hibernate Quick Start Guide.
I made a .NET class representing an entry of a table-row, wrote the mapping fileand created the config file just it is described in the guide.
Opening sessions and beginning transactions works all fine. Also I could read entries from database. However, when I modify a field in the class and try to flush it, I get a NHibernate.ADOException as follows.
Here is a codesnippet:
Code:
ISessionFactory factory = cfg.BuildSessionFactory();
ISession session = factory.OpenSession();
ITransaction transaction = session.BeginTransaction();
SalesAgent sa = (SalesAgent)session.Load(typeof(SalesAgent), 200);
sa.ChangeDate = DateTime.Now;
session.Flush();
transaction.Commit();
session.Close();
At the Flush-Statement this exception-message occurs:
Code:
could not update: [Test01.SalesAgent#200][SQL: UPDATE [it2m].[SalesAgent] SET MainSalesAgentID = ?, SalesAgentSK = ?, PartnerID = ?, LogInUserName = ?, LogInPassword = ?, MasterPassword = ?, Enabled = ?, Supervisor = ?, ChangeDate = ?, ValidFrom = ?, ValidTo = ? WHERE SalesAgentID = ?]
My first thought was the record values could not be read from the class, but the generated SQL seems OK for me:
Code:
NHibernate: UPDATE [it2m].[SalesAgent] SET MainSalesAgentID = @p0, SalesAgentSK = @p1, PartnerID = @p2, LogInUserName = @p3, LogInPassword = @p4, MasterPassword = @p5, Enabled = @p6, Supervisor = @p7, ChangeDate = @p8, ValidFrom = @p9, ValidTo = @p10 WHERE SalesAgentID = @p11; @p0 = '0', @p1 = '1392', @p2 = '1ae106ed-5e6f-465c-809d-00efb0027a8d', @p3 = 'ABC', @p4 = 'd41d8cd98f00b204e9800998ecf8427e', @p5 = 'masta', @p6 = 'True', @p7 = 'False', @p8 = '08.05.2007 22:51:41', @p9 = '09.01.2007 00:00:00', @p10 = '31.12.9999 00:00:00', @p11 = '200'
I'm using MS SQL Server 2005 Express and NHibernate V1.2.0
I hope for any help! ;-)
Regards!