照着上面的例子做了,怎么不能用啊。
错误如下:
错误
1NHibernate.MappingException: Could not compile the mapping document: QuickStart.Cat.hbm.xml ---> NHibernate.HibernateException: The dialect was not set. Set the property hibernate.dialect. at NHibernate.Dialect.Dialect.GetDialect() in D:\NHibernate-1.2.0.Beta2-debug\src\NHibernate\Dialect\Dialect.cs:line 460 at NHibernate.Dialect.Dialect.GetDialect(IDictionary props) in D:\NHibernate-1.2.0.Beta2-debug\src\NHibernate\Dialect\Dialect.cs:line 480 at NHibernate.Cfg.Configuration.AddValidatedDocument(XmlDocument doc, String name) in D:\NHibernate-1.2.0.Beta2-debug\src\NHibernate\Cfg\Configuration.cs:line 409 --- 内部异常堆栈跟踪的结尾 --- at NHibernate.Cfg.Configuration.LogAndThrow(MappingException me) in D:\NHibernate-1.2.0.Beta2-debug\src\NHibernate\Cfg\Configuration.cs:line 249 at NHibernate.Cfg.Configuration.AddValidatedDocument(XmlDocument doc, String name) in D:\NHibernate-1.2.0.Beta2-debug\src\NHibernate\Cfg\Configuration.cs:line 415 at NHibernate.Cfg.Configuration.AddXmlReader(XmlTextReader hbmReader, String name) in D:\NHibernate-1.2.0.Beta2-debug\src\NHibernate\Cfg\Configuration.cs:line 1575 at NHibernate.Cfg.Configuration.AddInputStream(Stream xmlInputStream, String name) in D:\NHibernate-1.2.0.Beta2-debug\src\NHibernate\Cfg\Configuration.cs:line 480 at NHibernate.Cfg.Configuration.AddResource(String path, Assembly assembly) in D:\NHibernate-1.2.0.Beta2-debug\src\NHibernate\Cfg\Configuration.cs:line 517 at NHibernate.Cfg.Configuration.AddAssembly(Assembly assembly, Boolean skipOrdering) in D:\NHibernate-1.2.0.Beta2-debug\src\NHibernate\Cfg\Configuration.cs:line 634 at NHibernate.Cfg.Configuration.AddAssembly(Assembly assembly) in D:\NHibernate-1.2.0.Beta2-debug\src\NHibernate\Cfg\Configuration.cs:line 596 at NHibernate.Cfg.Configuration.AddAssembly(String assemblyName) in D:\NHibernate-1.2.0.Beta2-debug\src\NHibernate\Cfg\Configuration.cs:line 577 at QuickStart.WebForm1.Button1_Click(Object sender, EventArgs e) in c:\inetpub\wwwroot\quickstart\webform1.aspx.cs:line 56
请高手指点一二。。不胜感激。。
自己乱试,出来了:原来就是和原来没啥变化。。就记得把Cat.hbm.xml变成嵌入的资源。。
之前把Web.config里的 <mapping assembly="QuickStart" /> 去掉了,在程序里加的Cfg.addAssembly("QuickStart")这样做总报上面的错误,在跟踪程序里发现IDictionary properties里只有一个"True"值,是Nhibernate没有加入配置原因。还在努力学习中。
感觉这个类库提供的Mapping在面向对象开发中,还是不错的,从对象到数据库设计,这样的思路应该可以让程序员不在把大部分精力来接SQL,而是转到业务上来。
学习Ing...