我在 Windows Server 2003 中使用带有 NHibernate-2.1.2.GA 的 Visual Studio 2005。
我尝试在我的 ASP.net 程序中将 oracle 与 NHibernate 连接起来。
要获取我的 oracle 版本,我运行以下 SQL:select * from v$version
结果显示 oracle 版本为oracle9i
.
所以,我这样写NHibernate.cfg.xml
:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2" >
<session-factory>
<property name="connection.driver_class">NHibernate.Driver.OracleClientDriver</property>
<property name="connection.connection_string">
Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521)))
(CONNECT_DATA=(SERVICE_NAME=MYORACLE)));
user id=team;password=team;
</property>
<property name="adonet.batch_size">10</property>
<property name="show_sql">true</property>
<property name="dialect">NHibernate.Dialect.Oracle9iDialect</property>
<property name="use_outer_join">true</property>
<property name="command_timeout">10</property>
<property name="query.substitutions">true 1, false 0, yes 'Y', no 'N'</property>
<property name="proxyfactory.factory_class">
NHibernate.ByteCode.Castle.ProxyFactoryFactory,
NHibernate.ByteCode.Castle
</property>
<mapping assembly="NHibernateSample.Domain"/>
</session-factory>
</hibernate-configuration>
现在,当我运行尝试连接 oracle 并执行查询 sql 的测试单元时:
private ISession _session;
private SessionManager _helper;
private NHibernateSample _sample;
public void TestFixtureSetup()
{
_helper = new SessionManager();
}
public void Setup()
{
_session = _helper.GetSession();
_sample = new NHibernateSample(_session);
}
[NUnit.Framework.Test]
public void GetCustomerById1Test()
{
TestFixtureSetup();
Setup();
NHibernateSample _sample = new NHibernateSample(_session);
Assert.AreEqual(1, _sample.GetCustomerById(1).Id);
}
它报告如下错误:
Test 'NHibernateSample.Data.Test.NHibernateSampleFixture.GetCustomerById1Test' failed: NHibernate.MappingException : Could not compile the mapping document: NHibernateSample.Domain.Mappings.Customer.hbm.xml
----> NHibernate.HibernateException : Could not instantiate dialect class NHibernate.Dialect.Oracle9iDialect
----> System.TypeLoadException : Could not load type org.NHibernate.Dialect.Oracle9iDialect. Possible cause: no assembly name specified.
我知道这是初学者的问题,但我只是一个新手!我很欣赏你的想法...