-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Invalid Column Name exception from QuickStart Example
PostPosted: Sat Jun 17, 2006 10:00 am 
Newbie

Joined: Sat Jun 17, 2006 9:44 am
Posts: 6
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


Top
 Profile  
 
 Post subject: Use fully qualified names
PostPosted: Sat Jun 17, 2006 10:21 am 
Newbie

Joined: Sat Jun 17, 2006 9:44 am
Posts: 6
I think I found the problem; when I use fully qualified names in the Hibernate Mapping file it seems to be working just fine. Like this:

Quote:
<class name="NHibernate.Examples.QuickStart.User, NHibernate.Examples" table="[NHibernate].[dbo].[Users]">


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.