Hibernate version:
released on 03/5/2007 1.2.0.GA
My platform VS2005+SqlServer2005 express
i was following the guide on
http://www.hibernate.org/362.html.
Error
NHibernate.HibernateException: The dialect was not set. Set the property hibernate.dialect
Here is my steps...
1 create the database.
Code:
CREATE TABLE users (
LogonID nvarchar(20) NOT NULL default '0',
Name nvarchar(40) default NULL,
Password nvarchar(20) default NULL,
EmailAddress nvarchar(40) default NULL,
LastLogon datetime default NULL,
PRIMARY KEY (LogonID)
)
go
2 I create a Class library project in VS2005.
Create the Class User. (The code is the same as the tutorial)
3 add the User.hbm.xml in the class library.(the same path as the Class User)
here is the content....
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="NHibernate.Examples.QuickStart.User, NHibernate.Examples" table="users">
<id name="Id" column="LogonId" type="String" length="20">
<generator class="assigned" />
</id>
<property name="UserName" column="Name" type="String" length="40"/>
<property name="Password" type="String" length="20"/>
<property name="EmailAddress" type="String" length="40"/>
<property name="LastLogon" type="DateTime"/>
</class>
</hibernate-mapping>
I didnot make any change in this xml file.
4I changed the Build Action to "Embeded Resourse" , and build the
assembly named NHibernate.Examples.5 I created a web project and added refference to NHibernate.dll and the assambly I just created...
6 I created the app.config file in the Web Project as follows...
Code:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section
name="nhibernate"
type="System.Configuration.NameValueSectionHandler, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
/>
</configSections>
<nhibernate>
<add
key="hibernate.connection.provider"
value="NHibernate.Connection.DriverConnectionProvider"
/>
<add
key="hibernate.dialect"
value="NHibernate.Dialect.MsSql2000Dialect"
/>
<add
key="hibernate.connection.driver_class"
value="NHibernate.Driver.SqlClientDriver"
/>
<add
key="hibernate.connection.connection_string"
value="Data Source=NOTEBOOK\SQLEXPRESS;Initial Catalog=Nhibernate;Integrated Security=True"
/>
</nhibernate>
</configuration>
I only change the connectString according to my database.
7 I created a index.aspx and wrote the following code in Pade_Load event
Code:
Configuration cfg = new Configuration();
cfg.AddAssembly("NHibernate.Examples");
ISessionFactory factory = cfg.BuildSessionFactory();
ISession session = factory.OpenSession();
ITransaction transaction = session.BeginTransaction();
User newUser = new User();
newUser.Id = "joe_cool";
newUser.UserName = "Joseph Cool";
newUser.Password = "abc123";
newUser.EmailAddress = "joe@cool.com";
newUser.LastLogon = DateTime.Now;
// Tell NHibernate that this object should be saved
session.Save(newUser);
// commit all of the changes to the DB and close the ISession
transaction.Commit();
session.Close();
TextBox1.Text = "Succeed.....";
but When I run it ....The error message is
NHibernate.HibernateException: The dialect was not set. Set the property hibernate.dialect.
and
line 15: {
line 16: Configuration cfg = new Configuration();
line 17: cfg.AddAssembly("NHibernate.Examples");
line 18: ISessionFactory factory = cfg.BuildSessionFactory();
行 19: ISession session = factory.OpenSession();