Every time load the hbm.xml file,I met this problem. Could not find the dialect in the configuration And below it's my code. 1 app.config <?xml version="1.0" encoding="utf-8" ?> <configuration> <configSections> <section name="nhibernate" type="System.Configuration.NameValueSectionHandler, System, Version=2.0.1.4000,Culture=neutral, PublicKeyToken=b77a5c561934e089,Custom=null" /> </configSections> <nhibernate xmlns="urn:nhibernate-configuration-2.2"> <add key="hibernate.connection.provider" value="NHibernate.Connection.DriverConnectionProvider" /> <add key="hibernate.prepare_sql" value="false" /> <add key="hibernate.cache.provider_class" value="NHibernate.Caches.SysCache.SysCacheProvider, NHibernate.Caches.SysCache" /> <add key="relativeExpiration" value="30" />
<add key="hibernate.dialect" value="NHibernate.Dialect.Oracle9Dialect"/> <add key="hibernate.connection.driver_class" value="NHibernate.Driver.OracleDataClientDriver" /> <add key="hibernate.connection.connection_string" value="Data Source=DATABASE;Persist Security Info=True;User ID=cyd;Password=cyd;Unicode=True;" /> <add key="hibernate.hbm" value="CorpTemplate.Business" /> <property name="dialect">NHibernate.Dialect.Oracle9Dialect </property> </nhibernate> </configuration>
2 userinfor class namespace NHibernateLearning { public class UserInfor { private string _userID; public string UserID { get { return _userID; } set { _userID = value; } }
private string _userName; public string UserName { get { return _userName; } set { _userName = value; } } } }
3. UserInfor.hbm.xml <?xml version="1.0" encoding="utf-8" ?> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.0" assembly="NHibernateLearning" namespace="NHibernateLearning"> <class name="NHibernateLearning.UserInfor, UserInfor" table="userinfor"> <id name="UserID" column="userid" type="string"> <generator class="native" /> </id> <property name="userName" column= "userName" type="string" length="20"/> </class> </hibernate-mapping>
4 form
public Form1() { 1 InitializeComponent();
2 mCfg.AddXmlFile("D:\\C#\\NHibernateLearning\\NHibernateLearning\\UserInfor.hbm.xml");
3 sessionFactory = mCfg.BuildSessionFactory(); } every time when the program runs to the line 2 ,I will meet this problem. Could not compile the mapping document: D:\\C#\\NHibernateLearning\\NHibernateLearning\\UserInfor.hbm.xml"} and the inner exception is Could not find the dialect in the configuration I have set the UserInfor.hbm.xml's property to the Embedded Resource. Is there some body can help me. I just start to learn Nhibernate. Thanks a lot!
|