I rewrote the .config file to connect to MySQL instead of SQL Server, to see how well NHibernate could just switch databases, and I ran into a problem. I'll include the relevant log4net log output at the bottom of this post. Here is what I believe is the relevant context:
The database is successfully built by NHibernate.
Adding some entities seems to work fine, but others seem to cause the error.
I have unicode strings with spanish, portuguese, and japanese characters that I'm saving to the database.
I installed MySQL 4.1.13a for Windows to default to the utf-8 character set.
I am using the MySQL Connector Net 1.0.4.
Below is the log output. Any help would be greatly appreciated!
Code:
2005-08-16 17:14:01,261 [TestCasemanager::ExecutionThread] DEBUG NHibernate.Persister.EntityPersister [(null)] <(null)> - Inserting entity: Byu.Fhss.Sfl.Purchasing.Product (native id)
2005-08-16 17:14:01,261 [TestCasemanager::ExecutionThread] DEBUG NHibernate.Impl.BatcherImpl [(null)] <(null)> - Opened new IDbCommand, open IDbCommands :1
2005-08-16 17:14:01,261 [TestCasemanager::ExecutionThread] DEBUG NHibernate.Impl.BatcherImpl [(null)] <(null)> - Building an IDbCommand object for the SqlString: INSERT INTO product (Name, Price) VALUES (:Name, :Price)
2005-08-16 17:14:01,261 [TestCasemanager::ExecutionThread] DEBUG NHibernate.Impl.BatcherImpl [(null)] <(null)> - Opened new IDbCommand, open IDbCommands :2
2005-08-16 17:14:01,261 [TestCasemanager::ExecutionThread] DEBUG NHibernate.Impl.BatcherImpl [(null)] <(null)> - Building an IDbCommand object for the SqlString: SELECT LAST_INSERT_ID()
2005-08-16 17:14:01,261 [TestCasemanager::ExecutionThread] DEBUG NHibernate.Persister.EntityPersister [(null)] <(null)> - Dehydrating entity: Byu.Fhss.Sfl.Purchasing.Product#
2005-08-16 17:14:01,261 [TestCasemanager::ExecutionThread] DEBUG NHibernate.Type.NullableType [(null)] <(null)> - binding 'READY' to parameter: 0
2005-08-16 17:14:01,261 [TestCasemanager::ExecutionThread] DEBUG NHibernate.Type.NullableType [(null)] <(null)> - binding '10' to parameter: 1
2005-08-16 17:14:01,261 [TestCasemanager::ExecutionThread] INFO NHibernate.Impl.BatcherImpl [(null)] <(null)> - Preparing INSERT INTO product (Name, Price) VALUES (?p0, ?p1)
2005-08-16 17:14:01,261 [TestCasemanager::ExecutionThread] ERROR NHibernate.Persister.EntityPersister [(null)] <(null)> - #42000You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '10)' at line 1
MySql.Data.MySqlClient.MySqlException: #42000You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '10)' at line 1
at MySql.Data.MySqlClient.PacketReader.CheckForError()
at MySql.Data.MySqlClient.PacketReader.ReadHeader()
at MySql.Data.MySqlClient.PacketReader.OpenPacket()
at MySql.Data.MySqlClient.NativeDriver.ReadResult(UInt64& affectedRows, Int64& lastInsertId)
at MySql.Data.MySqlClient.CommandResult.ReadNextResult(Boolean isFirst)
at MySql.Data.MySqlClient.NativeDriver.SendQuery(Byte[] bytes, Int32 length, Boolean consume)
at MySql.Data.MySqlClient.MySqlCommand.GetNextResultSet(MySqlDataReader reader)
at MySql.Data.MySqlClient.MySqlCommand.Consume()
at MySql.Data.MySqlClient.MySqlCommand.ExecuteNonQuery()
at NHibernate.Impl.BatcherImpl.ExecuteNonQuery(IDbCommand cmd)
at NHibernate.Persister.EntityPersister.Insert(Object[] fields, Boolean[] notNull, SqlString sql, Object obj, ISessionImplementor session)
2005-08-16 17:14:01,292 [TestCasemanager::ExecutionThread] DEBUG NHibernate.Impl.BatcherImpl [(null)] <(null)> - Closed IDbCommand, open IDbCommands :1
2005-08-16 17:14:01,292 [TestCasemanager::ExecutionThread] DEBUG NHibernate.Impl.BatcherImpl [(null)] <(null)> - Closed IDbCommand, open IDbCommands :0
2005-08-16 17:14:01,292 [TestCasemanager::ExecutionThread] ERROR NHibernate.ADOException [(null)] <(null)> - Could not save object
MySql.Data.MySqlClient.MySqlException: #42000You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '10)' at line 1
at MySql.Data.MySqlClient.PacketReader.CheckForError()
at MySql.Data.MySqlClient.PacketReader.ReadHeader()
at MySql.Data.MySqlClient.PacketReader.OpenPacket()
at MySql.Data.MySqlClient.NativeDriver.ReadResult(UInt64& affectedRows, Int64& lastInsertId)
at MySql.Data.MySqlClient.CommandResult.ReadNextResult(Boolean isFirst)
at MySql.Data.MySqlClient.NativeDriver.SendQuery(Byte[] bytes, Int32 length, Boolean consume)
at MySql.Data.MySqlClient.MySqlCommand.GetNextResultSet(MySqlDataReader reader)
at MySql.Data.MySqlClient.MySqlCommand.Consume()
at MySql.Data.MySqlClient.MySqlCommand.ExecuteNonQuery()
at NHibernate.Impl.BatcherImpl.ExecuteNonQuery(IDbCommand cmd)
at NHibernate.Persister.EntityPersister.Insert(Object[] fields, Boolean[] notNull, SqlString sql, Object obj, ISessionImplementor session)
at NHibernate.Persister.EntityPersister.Insert(Object[] fields, Object obj, ISessionImplementor session)
at NHibernate.Impl.ScheduledIdentityInsertion.Execute()
at NHibernate.Impl.SessionImpl.DoSave(Object obj, Key key, IClassPersister persister, Boolean replicate, Boolean useIdentityColumn, CascadingAction cascadeAction, Object anything)
at NHibernate.Impl.SessionImpl.DoSave(Object obj, Object id, IClassPersister persister, Boolean useIdentityColumn, CascadingAction cascadeAction, Object anything)
at NHibernate.Impl.SessionImpl.SaveWithGeneratedIdentifier(Object obj, CascadingAction action, Object anything)
[/list]