-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Error: The dialect was not set... Looking for help
PostPosted: Wed May 23, 2007 8:26 am 
Newbie

Joined: Wed May 23, 2007 7:41 am
Posts: 1
Location: Shanghai,China
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();

_________________
I am on my way...


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 23, 2007 10:50 am 
Newbie

Joined: Thu Mar 15, 2007 10:11 am
Posts: 19
Location: Dallas
It clearly says the hibernate.dialect was not set. you need to set it to the class name depending on what database you are using.
Don't forget to rate.


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 23, 2007 11:05 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
Web projects use web.config, not app.config.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.