views:

1167

answers:

2

Hey, I'm trying to run an NHibernate over sqlite. i have two projects: 1. Orange.Database - holds the pocos and daos and everything else 2. Orange.GUI - holds the gui...

when the program reach to the reach the:

  Configuration config = new Configuration();
  config.AddAssembly("Orange.Database");
  sessionFactory = config.Configure().BuildSessionFactory();

an exception is thrown: "Could not compile the mapping document: Orange.Database.Pocos.City.hbm.xml " inner exception: "Could not find the dialect in the configuration"

city.hbm.xml:

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
               namespace="Orange.Database.Pocos">


<class name="City" table="Cities">
<id name="Id">
  <column name="Id" sql-type="int" not-null="true"/>
  <generator class="identity"/>
</id>

<property name="Name">
  <column name="name" not-null="true"/>
</property>

<property name="IsTaxFree">
  <column name="is_tax_free" not-null="true"/>
</property>
</class>
</hibernate-mapping>

I tried writting the assembly, and then removed it..

the app.config file:

<?xml version="1.0" encoding="utf-8" ?>

<configSections>

<section name="hibernate-configuration"
type="NHibernate.Cfg.ConfigurationSectionHandler,NHibernate"/>

  </configSections>

<hibernate-configuration  xmlns="urn:nhibernate-configuration-2.2" >
<session-factory>

<property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
  <property name="connection.driver_class">NHibernate.Driver.SQLiteDriver</property>
  <property name="connection.connection_string">
    Data Source=C:\Users\Nadav\Documents\Visual Studio 2005\Projects\orange\DB\OrangeDB\OrangeDB.db;Version=3
  </property>
  <property name="dialect">NHibernate.Dialect.SQLiteDialect</property>
  <property name="query.substitutions">true=1;false=0</property>

</session-factory>
</hibernate-configuration>
</configuration>

I've tried different location of the db file.. i have tried to remove the configSections and some other ideas i found on the web...

I'm using vs 2005 NHibernate version is 2.0.1.4000

Any suggestions?

A: 

First, download the latest stable version of NHibernate, 2.1.2.

Second, try creating a configuration file named hibernate.cfg.xml, containing:

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
    <session-factory>
     <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
     <property name="connection.driver_class">NHibernate.Driver.SQLiteDriver</property>
     <property name="connection.connection_string">
      Data Source=C:\Users\Nadav\Documents\Visual Studio 2005\Projects\orange\DB\OrangeDB\OrangeDB.db;Version=3
     </property>
     <property name="dialect">NHibernate.Dialect.SQLiteDialect</property>
     <property name="query.substitutions">true=1;false=0</property>
     <property name="proxyfactory.factory_class">NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle</property>
    </session-factory>
</hibernate-configuration>
Diego Mijelshon
Thanks for the answer.i Updated NHibernate version to 2.1.0.4000adde the hibernate.cfg.xml to the root directory added castle.core castle.DynamicProxy2 and NHibernate.ByteCode.castleand I'm still getting:message: Could not compile the mapping document: Orange.Database.Pocos.City.hbm.xmlinner: Could not find the dialect in the configurationthanks again..
Nadav
Are you sure hibernate.cfg.xml is being copied to the bin folder?
Diego Mijelshon
A: 

do this in your code:

Configuration config = new Configuration();
config.Configure();
config.AddAssembly("Orange.Database");
sessionFactory = config.BuildSessionFactory();
saeed