As a new NHibernate user, I've decided to give the QuickStart Example a go. The first couple of exceptions I was able to fend off myself (for some reason I had to make all the accessors virtual in the User class to allow for proxy generation). Now, when I try to run the application, the configuration gets built and I am able to open a session. However as soon as I try to persist a new User object to the users table (or try to query the table for that matter) I get the following error:
Quote:
Unhandled Exception: NHibernate.ADOException: could not insert: [NHibernate.Examples.QuickStart.User#JQ] ---> System.Data.SqlClient.SqlException: Invalid column name 'Name'.
Invalid column name 'LastLogon'.
Invalid column name 'EmailAddress'.
Invalid column name 'Password'.
Invalid column name 'LogonId'.
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) in c:\net\nhibernate\nhibernate\src\NHibernate\Impl\BatcherImpl.cs:line 208
at NHibernate.Impl.NonBatchingBatcher.AddToBatch(Int32 expectedRowCount) in c:\net\nhibernate\nhibernate\src\NHibernate\Impl\NonBatchingBatcher.cs:line 34
at NHibernate.Persister.Entity.SingleTableEntityPersister.Insert(Object id, Object[] fields, Boolean[] notNull, SqlString sql, Object obj, ISessionImplementor session) in c:\net\nhibernate\nhibernate\src\NHibernate\Persister\Entity\SingleTableEntityPersister.cs:line 539
--- End of inner exception stack trace ---
at NHibernate.Persister.Entity.SingleTableEntityPersister.Insert(Object id, Object[] fields, Boolean[] notNull, SqlString sql, Object obj, ISessionImplementor session) in c:\net\nhibernate\nhibernate\src\NHibernate\Persister\Entity\SingleTableEntityPersister.cs:line 549
at NHibernate.Persister.Entity.SingleTableEntityPersister.Insert(Object id, Object[] fields, Object obj, ISessionImplementor session) in c:\net\nhibernate\nhibernate\src\NHibernate\Persister\Entity\SingleTableEntityPersister.cs:line 496
at NHibernate.Impl.ScheduledInsertion.Execute() in c:\net\nhibernate\nhibernate\src\NHibernate\Impl\ScheduledInsertion.cs:line 38
at NHibernate.Impl.SessionImpl.Execute(IExecutable executable) in c:\net\nhibernate\nhibernate\src\NHibernate\Impl\SessionImpl.cs:line 3163
at NHibernate.Impl.SessionImpl.ExecuteAll(IList list) in c:\net\nhibernate\nhibernate\src\NHibernate\Impl\SessionImpl.cs:line 3142
at NHibernate.Impl.SessionImpl.Execute() in c:\net\nhibernate\nhibernate\src\NHibernate\Impl\SessionImpl.cs:line 3094
at NHibernate.Impl.SessionImpl.Flush() in c:\net\nhibernate\nhibernate\src\NHibernate\Impl\SessionImpl.cs:line 2930
at NHibernate.Transaction.AdoTransaction.Commit() in c:\net\nhibernate\nhibernate\src\NHibernate\Transaction\AdoTransaction.cs:line 141
at NHibernate.Examples.QuickStart.Program.Main(String[] args) in C:\Inetpub\Hibernate\NHibernate-QuickStartGuide\Program.cs:line 35
Of course my class is exactly the same as the one in the QuickStart guide (except for the virtual modifiers on the accessors) and the User.hbm.xml mapping file is just a direct copy-paste, so I'll refrain from pasting those source listings here.
I do not have SQL Server 2000, so I had to use SQL Server 2005 Express for the needed NHibernate example database and altered the Hibernate dialect in the App.config accordingly to:
Quote:
<add
key="hibernate.dialect"
value="NHibernate.Dialect.MsSql2005Dialect"
/>
What am I doing wrong? I've checked the spelling over and over and I'm pretty sure I copied the column names correctly. Or am I missing something else here?
PS: Using the
NHibernate-1.2.0.Alpha1-debug version