NHibernate and sqlite - failed to compile mapping document

I am trying to run NHibernate over sqlite. I have two projects: 1. Orange.Database - contains pocos and daos and everything else 2. Orange.GUI - contains gui ...

when the program reaches reach:

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

an exception is thrown: "Failed to compile the mapping document: Orange.Database.Pocos.City.hbm.xml" internal 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 to overlay the assembly and then deleted it.

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 tried different location of db file. I tried to remove configSections and some other ideas that I found on the Internet ...

I am using vs 2005 NHibernate version - 2.0.1.4000

Any suggestions?

0
mapping sqlite nhibernate
source share
3 answers

First download the latest stable version of NHibernate, 2.1.2.

Secondly, try creating a configuration file called 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> 
0
source share

Do this in your code:

 Configuration config = new Configuration(); config.Configure(); config.AddAssembly("Orange.Database"); sessionFactory = config.BuildSessionFactory(); 
+2
source share

I got the same "failed to compile error", but I do not use sqlite.

I got it because I called the configure method twice from the nhibernate configuration instance.

0
source share

All Articles