一個下午,差不多都耗在這個XXOO上了!
VS2008, Mvc 1.0, NHibernate 2.2, MySql XX, 按照 NH 官方樣本配置 Web.config
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2" > <session-factory name="NHibernate.Test"> <property name="connection.driver_class">NHibernate.Driver.MySqlDataDriver</property> <property name="connection.connection_string"> Database=test;Data Source=someip;User Id=blah;Password=blah </property> <property name="dialect">NHibernate.Dialect.MySQLDialect</property> <property name="proxyfactory.factory_class">NHibernate.ByteCode.LinFu.ProxyFactoryFactory, NHibernate.ByteCode.LinFu</property> </session-factory></hibernate-configuration>
然後運行出現黃頁:
“/”應用程式中的伺服器錯誤。--------------------------------------------------------------------------------列“ReservedWord”不屬於表 ReservedWords。 說明: 執行當前 Web 請求期間,出現未處理的異常。請檢查堆疊追蹤資訊,以瞭解有關該錯誤以及代碼中導致錯誤的出處的詳細資料。 異常詳細資料: System.ArgumentException: 列“ReservedWord”不屬於表 ReservedWords。源錯誤: 行 12: 行 13: static NHibernateHelper() {行 14: sessionFactory = new Configuration().Configure().BuildSessionFactory();行 15: }行 16: 源檔案: E:\Documents\SVN\MIS\project\OpenService\FilesII\FilesII.DAL\NHibernateHelper.cs 行: 14 堆疊追蹤: [ArgumentException: 列“ReservedWord”不屬於表 ReservedWords。] System.Data.DataRow.GetDataColumn(String columnName) +1773557 System.Data.DataRow.get_Item(String columnName) +13 NHibernate.Dialect.Schema.AbstractDataBaseSchema.GetReservedWords() +237 ...
寡人我輾轉 Google、百度 之中文資料,終不得解;無奈,偶見一外文網頁,點入、跟蹤,解決:
http://www.google.cn/search?hl=zh-CN&q=nhibernate+mysql+ReservedWord&btnG=Google+搜尋
https://forum.hibernate.org/viewtopic.php?f=25&t=997701
Barlog
Post subject: Re: Column 'ReservedWord' does not belong to table ReservedWords
Posted: Wed Jul 22, 2009 9:43 am
Newbie
Joined: Wed Jul 22, 2009 9:24 am
Posts: 1
Greetings.
Just add following line to configuration file to <session-factory> section.
<property name="hbm2ddl.keywords">none</property>
However this fix might cause unexpected problems.
Best regards.
_________________
Infinite diversity in infinite combination
我XX他個OO啊!!