NHibernate和sqlite-无法编译映射文档 [英] NHibernate and sqlite - Could not compile the mapping document
问题描述
我试图在sqlite上运行NHibernate. 我有两个项目: 1. Orange.Database-保存pocos和daos以及其他所有内容 2. Orange.GUI-持有GUI ...
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();
引发异常:无法编译映射文档:Orange.Database.Pocos.City.hbm.xml" 内部异常:在配置中找不到方言"
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:
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..
app.config文件:
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>
我尝试了db文件的其他位置. 我试图删除configSections 以及我在网络上发现的其他一些想法...
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...
我正在使用vs 2005 NHibernate版本是2.0.1.4000
I'm using vs 2005 NHibernate version is 2.0.1.4000
有什么建议吗?
推荐答案
首先,下载NHibernate 2.1.2的最新稳定版本.
First, download the latest stable version of NHibernate, 2.1.2.
第二,尝试创建一个名为hibernate.cfg.xml的配置文件,其中包含:
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>
这篇关于NHibernate和sqlite-无法编译映射文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!